This is my implementation in Go for the "Build Your Own Git" Challenge.
This is a small Git implementation that's capable of
initializing a repository, creating commits and cloning a public repository.
It's capable of handling the .git
directory, Git objects (blobs,
commits, trees etc.), Git's transfer protocols and more.
Note: Head over to codecrafters.io to try the challenge yourself.
Final implementation passes all stages of git-tester v43:
- Repository Setup
- Initialize the .git directory
- Read a blob object
- Create a blob object
- Read a tree object
- Write a tree object
- Create a commit
- Clone a repository
Only the "plumbing", low-level git commands for now (no add
, commit
, status
, etc.). Just enough to complete the stages above and pass all tests.
init
- Does the bare minimum. Only works on current directory.cat-file
- Can print size, type and contenthash-object
- Can calculate hash and write object to.git/objects
ls-tree
- Can list a single tree object (no recursion)write-tree
- Write entire working tree recursively (no index/staging area yet)commit-tree
- Write a commit objectclone
- Only working with remote, Smart HTTP (e.g. GitHub), repositories. Doesn't create an index yet, i.e. does just enough to pass the last stage above. Runninggit checkout master
can create the index properly, though.
Continue implementing support for more subcommands as described in the Git challenge from Coding Challenges.
The your_git.sh
script is expected to operate on the .git
folder inside the
current working directory. If you're running this inside the root of this
repository, you might end up accidentally damaging your repository's .git
folder.
We suggest executing your_git.sh
in a different folder when testing locally.
For example:
mkdir -p /tmp/testing && cd /tmp/testing
/path/to/your/repo/your_git.sh init
To make this easier to type out, you could add a shell alias:
alias mygit=/path/to/your/repo/your_git.sh
mkdir -p /tmp/testing && cd /tmp/testing
mygit init