Understanding Git from its objects outwards

Summary

Mary Rose Cook explains Git by building up blobs, trees, commits, branches, merges and rebases step by step. Git stores objects in the .git/objects directory.

Ideas

  • Blobs store immutable file contents.
  • Trees map names to stored objects.
  • Commits link a tree with parents and metadata.
  • Branches are mutable pointers to commit objects.

Insights

  • Git's interface becomes understandable once its data model is visible.
  • Content addressing simplifies verification, deduplication and exchange.
  • History forms a graph rather than a linear list.

Facts

  • Object names are derived from hash values.
  • Merge commits have several parents.

Recommendations

  • Examine a test repository with git cat-file.
  • Draw commit graphs before complex history operations.

References

Read the original article

Search the Web Archive

Found a mistake or have something to add? Get in touch.