Skip to content

Latest commit

Β 

History

History
82 lines (58 loc) Β· 2.4 KB

File metadata and controls

82 lines (58 loc) Β· 2.4 KB

Ge-Git – Build Your Own Git in C

Ge-Git Logo

Ge-Git is a lightweight Git implementation in C that mimics Git's internal object storage system, including support for blob, tree, and commit objects.


πŸš€ Features

  • βœ… init – Initialize a .gegit directory
  • βœ… hash-object – Create blob objects from file content
  • βœ… write-tree – Generate tree objects from directory structure
  • βœ… commit – Create commit objects referencing tree objects
  • βœ… Stores all Git-like objects in .gegit/objects/<sha1>

🧠 Internals

This project closely follows how Git internally handles content:

Object Type Format Stored In
Blob blob <size>\0<content> .gegit/objects/<first2>/<rest38>
Tree tree <size>\0<entries> per file .gegit/objects/<sha1>
Commit commit <size>\0tree <sha>\nauthor...\n<message> .gegit/objects/<sha1>

πŸ“¦ File Structure

Ge-Git/
β”œβ”€β”€ .gegit/                  # Custom .git-like directory for storing objects
β”‚   └── objects/             # Contains all git objects (blobs, trees, commits)
β”‚       └── <hash-prefix>/
β”‚           └── <object-file>
β”œβ”€β”€ .vscode/                 # VS Code settings (optional)
β”œβ”€β”€ include/                # Header files
β”‚   β”œβ”€β”€ commit.h
β”‚   β”œβ”€β”€ hash_object.h
β”‚   β”œβ”€β”€ init.h
β”‚   β”œβ”€β”€ tree.h
β”‚   └── utils.h
β”œβ”€β”€ src/                    # Source files
β”‚   β”œβ”€β”€ commit.c
β”‚   β”œβ”€β”€ hash_object.c
β”‚   β”œβ”€β”€ init.c
β”‚   β”œβ”€β”€ tree.c
β”‚   └── utils.c
β”œβ”€β”€ hello.txt               # Sample file to hash
β”œβ”€β”€ main.c                  # CLI entry point
β”œβ”€β”€ gegit                   # Compiled binary
└── Makefile                # Build script


πŸ§ͺ Example Usage

🟒 Initialize repository

make

./gegit init

πŸ“¦ Hash a file as a blob

./gegit hash-object hello.txt

🌲 Write tree from current directory

./gegit write-tree

πŸ“ Commit the tree

./gegit commit "initial commit"

πŸͺͺ License

MIT License Β© Meerthika