go-gitter
I'm implementing git, in Go, from scratch. The goal is to learn both the Go language by doing a relatively challenging project, and the git internals.
The plan, of course, is not to implement 100% of git. I intend to implement only a small subset of the main commands, and even those, in their most basic variations.
It should go without saying, but this is a toy project. Don't use it for anything serious.
Implemented Commands
init — initializes a new repository
hash-object --stdin — computes the SHA-1 hash of content read from stdin
hash-object -w --stdin — same as above, but also writes the object to .git/objects
cat-file -p <hash> — prints the content of an object
cat-file -t <hash> — prints the type of an object
cat-file -s <hash> — prints the size of an object
update-index --add <file> — stages a single file to the index
Planned Commands
In rough order of implementation:
ls-files
write-tree
commit-tree
add
commit
log
status
I'm not sure whether I'll try to implement merge and anything involving networking. Most likely not, but let's see how this goes.
Building and Installing
# Install from source
go install github.com/carlosschults/go-gitter@latest
# Or build locally
make build
Running the Tests
make test
License
MIT