The Git Challenge

Early Access

In this challenge, you’ll build a toy Git implementation that can clone a public repository, commit changes and push them back to a git server. Along the way, you’ll learn about the .git directory, a few of Git’s “plumbing” commands, Git objects (blobs, commits, trees etc.), Git’s transfer protocols and more.

This challenge has 8 stages.

#1

Initialize the .git directory

In this stage, you’ll implement the git init command. You’ll initialize a git repository by creating a .git directory and some files inside it.

#2

Create a blob object

In this stage, you’ll add a file to your git repository by creating a blob object and persisting it in the .git/objects directory.

You’ll do this using the first of multiple “plumbing” commands we’ll encounter in thie challenge: git hash-object.

#3

Read a blob object

In the previous stage, we learnt how to persist a blob. In this stage, we’ll read a blob that already exists in storage by implementing the git cat-file command.

#4

Read a tree object

Now that we’ve learnt how to read/write blobs, let’s move onto our next Git object: the tree. In this stage, you’ll read a tree object from storage by implementing the git ls-tree command.

#5

Write a tree object

In this stage, you’ll write a tree to git storage by implementing the git write-tree command.

To keep things simple, we won’t implement an index, we’ll just assume that all changes in the worktree are staged.

#6

Create a commit

Let’s move on to the last git object we’ll be dealing with in this challenge: the commit. In this stage, you’ll create a commit with all the changes in the worktree by implementing git commit --all.

#7

Clone a repository

Time to interact with the real world! In this stage, you’ll clone a public repository from GitHub. To do this, you’ll use the Dumb HTTP transfer protocol.

#8

Push changes to a repository

This is the last stage of the challenge, and probably the hardest. You’ll implement the equivalent of git push, using the Smart HTTP transfer protocol.

Interested in trying out the Git Challenge? Signup for our Early Access program!