git-from-the-bottom-up

Introduction

Welcome to the world of Git. I hope this document will help to advance your understanding of this powerful content tracking system, and reveal a bit of the simplicity underlying it — however dizzying its array of options may seem from the outside.

Git Version Compatibility

This guide was originally written in 2014 and covers Git fundamentals that have remained stable across versions. The core concepts explained here — repositories, commits, branches, the index, and basic operations — work with any Git version from 1.7 onwards. While Git has added many features since then (such as worktrees, sparse checkouts, and improved performance), the foundational knowledge in this guide remains relevant for understanding Git at any version.

For those learning Git today, some notable improvements since this guide was written include:

However, the mental model and core commands described in this guide remain the foundation you need to understand Git effectively.

Before we dive in, there are a few terms which should be mentioned first, since they’ll appear repeatedly throughout this text:

The usual flow of events is this: After creating a repository, your work is done in the working tree. Once your work reaches a significant point — the completion of a bug, the end of the working day, a moment when everything compiles — you add your changes successively to the index. Once the index contains everything you intend to commit, you record its content in the repository. Here’s a simple diagram that shows a typical project’s life-cycle:

Project Lifecycle

With this basic picture in mind, the following sections shall attempt to describe how each of these different entities is important to the operation of Git.

LICENSE: This document is licensed under the Creative Commons BY 4.0 license. If you’d like to translate it into other languages, please feel free, so long as you reference this original text.