Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Git stores project history as objects: blobs hold file contents, trees describe directory structure, and commits connect a snapshot to its history. A branch is not a second copy of the project; it is a movable reference to a commit. The index stages content for a future commit, while HEAD identifies the current checkout.

How Git stores a project snapshot

A Git snapshot is represented by linked objects rather than by a full duplicate of every file for every commit. Git’s data model groups its concepts into objects, references, the index, and reflogs. The official Git data model manual identifies this terminology; the following objects make up the snapshot and its history.

Blob: file contents

A blob stores a file’s contents. If a commit changes two files in a large repository, Git can create blobs for the new contents and reuse existing blob IDs for unchanged contents. A snapshot therefore describes the complete project state without necessarily duplicating all of the file bytes.

Tree: names and directory structure

A tree represents a directory. Its entries record names, modes, and object IDs for files or child directories. File entries point to blobs; directory entries point to other trees. Nested trees let Git represent the project’s directory hierarchy.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Commit: a tree plus history

A commit points to the root tree for a project snapshot and stores metadata such as author, committer, and message. It also points to one or more parent commits. Following parent links traces the commit history; a merge commit can have multiple parents.

The official Pro Git book’s Git objects chapter explains these object types in more detail.

Are Git branches copies of a project?

No. A branch is a named, movable reference to a commit, not a separate directory or copy of the repository. As the Pro Git book puts it, “A branch in Git is simply a lightweight movable pointer to one of these commits.” When you create a commit on the current branch, Git advances that branch reference to the new commit. The commit and its snapshot objects remain in the object database.

Because a branch names a commit rather than a separate set of files, creating or switching branches does not, by itself, duplicate the project’s contents. Different branches can point to different commits, each of which identifies its own snapshot and history.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What happens when you stage and commit?

  1. git add prepares selected content in the index, the staging area for the next commit.

  2. git commit writes the necessary tree structure and a commit object for the staged snapshot.

  3. Git advances the current branch reference to the new commit. The reference names a point in the object database; it is not itself the snapshot.

The Pro Git objects chapter and references discussion provide further detail on objects and references.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How blobs, trees, commits, branches, the index, and HEAD differ

Concept What it represents
Blob File contents.
Tree A directory’s entries, including names, modes, and pointers to blobs or child trees.
Commit A pointer to a root tree, commit metadata, and parent commit pointer(s).
Branch A movable named reference to a commit.
Index Staged content prepared for a future commit, distinct from an existing commit’s tree.
HEAD An identifier for the current checkout. In the usual attached state, it symbolically refers to the current branch.

What to remember about Git’s storage model

  • Git objects are immutable once created and are identified by object IDs.
  • Blobs hold contents; trees connect names and directory structure to blobs and subtrees.
  • Commits point to snapshot trees and parent commits, linking project states into history.
  • Branches are movable references, not copies of project files.
  • The index stages changes, while HEAD identifies the current checkout.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.