Build your own Git

Build your own Git

Learn about git objects, plumbing commands, git transfer protocols and more
Difficulty
Hard
Attempts
264
Supported Languages
Python
Ruby
Go
Rust
Kotlin

Introduction

In this challenge, you’ll build a Git implementation that can initialize a repository, create commits and clone a public repository from GitHub. 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.

Testimonials

Stages

Initialize the .git directory
#1

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.

264 completions
Read a blob object
#2

In this stage, you’ll read a blob from your git repository by fetching its contents from the .git/objects directory.

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

122 completions
Create a blob object
#3

In the previous stage, we learnt how to read a blob. In this stage, we’ll persist a blob by implementing the git hash-object command.

102 completions
Read a tree object
#4

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.

85 completions
Write a tree object
#5

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.

56 completions
Create a commit
#6

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 by implementing the git commit-tree command.

51 completions
Clone a repository
#7

This is the last stage of the challenge, and probably the hardest! In this stage, you’ll clone a public repository from GitHub. To do this, you’ll use one of Git’s Transfer protocols.

15 completions