This is a quick introduction to the inner workings of Git, largely based on what I learned from reading Git Internals (https://peepcode.com/products/git-internals-pdf) and experimentation. It covers Git objects (blob, tree, commit, tag), references, and branches with incrementally building diagrams to help convey the concepts.
2. What’s Git?
Git is a free & open source, distributed version control
system designed to handle everything from small to very
large projects with speed and efficiency.
Every Git clone is a full-fledged repository with complete
history and full revision tracking capabilities, not dependent
on network access or a central server. Branching and
merging are fast and easy to do.
7. Git Objects
header object_type [content size]0
content of the file
can be text
content can be binary
can be whatever
Zlib::Deflate
8. Git Objects
header object_type [content size]0
content of the file
can be text
content can be binary
can be whatever
Zlib::Deflate
1 Blob 2 Tree 3 Commit 4 Tag
35. Tag Content
object 3848fa7e91490a99b77590ff1385c4b3eebb3de3
type commit
tag v1.0
tagger Jeff Kunkle <jkunkle@ni.com> Tue Dec 29 21:02:04 2009 -0500
version 1.0
>git cat-file -p v1.0
36. ./ tree : f2eb1e
Rakefile blob : 21a307
init.rb blob : 644eda
lib tree : 523fa4
grant.rb blob : a22a24
commit : 3848fa
tag : e9eff3
>git tag -a v1.0
37. ./ tree : f2eb1e
Rakefile blob : 21a307
init.rb blob : 644eda
lib tree : 523fa4
grant.rb blob : a22a24
commit : 3848fa
tag : e9eff3
>git tag -a v1.0
46. HEAD
branch tag
commit
tree blob
tree blob
blob
47. HEAD HEAD
branch tag branch
commit commit
tree blob tree
tree blob tree
blob blob
>git commit -a lib/grant.rb
48. HEAD HEAD HEAD
branch tag branch branch
commit commit commit
tree blob tree tree blob
tree blob tree blob
blob blob
>git commit -a Rakefile init.rb