This project involves reimplementing core Git functionality in Python. It will help you understand Git's internal architecture and make you comfortable with both its plumbing and porcelain commands.
You will implement a subset of Git commands, both low-level (plumbing) and user-facing (porcelain). Your goal is to ensure they behave similarly to real Git, within clearly defined constraints.
- Creates a blob object from file content and writes its SHA-1 to stdout.
- ❌ Reject directories or missing files.
-t
: Print object type.-p
: Pretty-print blob/tree/commit content.- ❌ Reject invalid OIDs or missing options.
- Create a tree object from the staging area.
- Writes SHA-1 of the tree to stdout.
- Creates a commit object pointing to a tree (and parent commit if any) and writes its oid to stdout
- Requires
-m
message. - ❌ No annotated tags.
- Initializes a Git repository in the given directory.
- Create .git/objects, .git/refs/heads, HEAD, and minimal config
- Adds files to the staging area (not directories).
- ❌ No
-p
, no wildcards.
- Removes a file from working directory and index.
- Runs
write-tree
, creates a commit with HEAD as parent. - ❌ No editor or message prompt.
- Shows staged and unstaged changes.
- Switch to existing commit or branch.
-b <branch>
creates a new branch.- Change HEAD, update working dir, check for conflicts
--soft
: move HEAD--mixed
: + reset index--hard
: + reset working directory- ❌ No file-specific reset.
- Print commit history from HEAD (one-line summary ok).
- List all files in the index.
- List contents of a tree object.
- Convert ref/branch/HEAD into SHA-1.
- ❌ No complex selectors
- List all refs and their hashes.
- Perform 3-way merge and create a merge commit with 2 parents.
- On conflict: insert
<<<<<<<
,=======
,>>>>>>>
markers into file(s). - ❌ No rebase, squash, or fast-forward-only merges.
- Handle
.gitignore
- Use simple glob-style matching (e.g.,
*.log
,build/
) - ❌ No negation or nested
.gitignore
files.
- You are free to implement the index your way.
- ✅ Bonus if it matches Git’s format closely.
git push
andgit update-index
are NOT required.- No support for remotes, rebase, tags, or stashing.
- A working implementation of the listed commands.
- Tests and example usage for each.
- Clean error handling for all unsupported cases.
- Total time: 6–9 days
- Use AI if needed, but understand what you're coding.
Good luck, and enjoy re-inventing Git!