Re-implementation of the git version control system in Rust
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A small re-implementation of git (a distributed version control system) written in Rust:

  • basic commands: init, config, add, commit, status, diff, log.
  • branches: branch, checkout, merge.
  • remotes: clone, fetch, push, pull, remote.
  • plumbing: hash-object, cat-file, ls-files, read-tree, write-tree.

Building it

$ cargo build --release
$ cd target/release
$ ./gitrs

Running it

$ mkdir repo
$ cd repo
$ gitrs init
Initialized empty Git repository in .git
$ gitrs config --add "John Doe"
$ gitrs config --add ""

$ echo 'Hello world!' > file_a
$ gitrs status
new: file_a
$ gitrs add file_a
$ gitrs commit -m "first commit"
[master 5b0cd52] first commit

$ cd ..
$ gitrs clone repo copy
Initialized empty Git repository in copy/.git
Count: 3 objects
From: /home/haltode/repo
Cloning into copy
$ cp repo/.git/config copy/.git/config
$ cd copy
$ echo 'new file' > file_b
$ gitrs add file_b
$ gitrs commit -m "second commit"
[master 3940393] second commit

$ cd ../repo
$ gitrs remote add copy_remote ../copy
$ gitrs branch new_b
$ gitrs pull copy_remote master
Count: 3 objects
From: ../copy

$ gitrs checkout new_b
Switched to branch new_b
$ echo 'new line' >> file_a
$ gitrs status
modified: file_a
$ gitrs diff
 Hello world!
$ gitrs add file_a
$ gitrs commit -m "third commit"
[new_b 9e4e36b] third commit
$ gitrs checkout master
Switched to branch master
$ gitrs merge new_b
Merge new_b into master
[master 7b8e051] Merge new_b into master

Resources used


I wanted a fun project to learn more about the Rust programming language and git inner workings at the same time. The sole purpose of this project is educational. As a challenge I also restricted myself to the Rust standard library, thus re-implementing everything else that I might need such as: sha-1 hash function, zlib compress/decompress functions, etc. This is absurd and definitely not good practice, but again the only aim was to learn, so every opportunity is a great excuse to code in Rust!