git graphs, hashes, and compression, oh my
TRANSCRIPT
at with Matthew McCullough
GitGraphs, Hashes, and Compression, Oh My!
© 2
012,
GitH
ub, I
nc.
@matthewmccull
github.com/training
GIT - the stupid content tracker
"git" can mean anything, depending on
your mood.
* random three-letter combination that
is pronounceable, and not actually
used by any
common UNIX command. The fact that it
is a mispronunciation of "get" may or
may not be
relevant.* stupid. contempti
ble and despicable. simple. Take your
pick from the dictionary of
slang.* "global informati
on tracker": you're in a good mood, an
d it actually works for you.
Angels sing, and a light suddenly fill
s the room.
* "goddamn idiotic truckload of sh*t":
when it breaks
Git is a fast, scalable, distributed r
evision control system with an unusual
ly rich
command set that provides both high-le
vel operations and full access to inte
rnals.
Git is an Open Source project covered
by the GNU General Public License. It
was originally
written by Linus Torvalds with help of
a group of hackers around the net. It
is currently
maintained by Junio C Hamano.
“
”
2005git
ArchitectureHashes
centralized VCSs use sequential revision numbers
Git uses a SHA-1 hash
40 hex characters (20 bytes)
9AB223D28B1AA46EF1780B22F304982E39872C34
9AB223D28B1AA46EF1780B22F304982E39872C34
<html><body>
<p>This is a test</p><img src="http://ai.com/icon.gif">
</body></html>
<html><body>
<p>This is a test</p><img src="http://ai.com/icon.gif">
</body></html>
9AB223D28B1AA46EF1780B22F304982E39872C34
Hashed ContentGit commits without Git
# Green field project$ git init newproject$ cd newproject# ...start coding
.git!"" COMMIT_EDITMSG!"" HEAD!"" MERGE_RR!"" config!"" description!"" hooks# !"" pre-commit.sample# $"" update.sample!"" index!"" info# $"" exclude!"" logs# !"" HEAD# $"" refs# $"" heads# $"" master!"" objects# !"" 54# # $"" 3b9bebdc6bd5c4b22136034a95dd097a57d3dd# !"" info# $"" pack!"" refs !"" heads # $"" master $"" tags
$ printf "blob 12\000Hello World\n" | shasum
ArchitectureHash Shortcuts
use as little of it as is unique
9AB223D28B1AA46EF1780B22F304982E39
872C34a certain commit
9AB22Fa certain commit
git rev-parse 9AB22Fexpand the commit ref
ArchitectureStorage
Typical SCMs use delta storage
CVS / Subversion / darcs / Mercurial
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
Δ Δ
ΔΔ ΔΔΔ
Checkin
Checkin Checkin Che
ckin
Che
ckin
Che
ckin
Che
ckin
Che
ckin
Check
in
Checkin
Checkin
Delta storage gets slower as the history of a file gets longer
Directed Acyclic Graph
Copy of the entire tree per checkin
cp -r srcfolder srcfolder.prev
Why?
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
hard link to existing identical blobs
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File Cß
zlib deflates each blob at commit
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
zlib deflates the entire repo
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
v1 v2 v3 v4
File A
File B
File C
File A
File B File B
File C
v5
File A
File BFile B
File A File A
File C File C File C
2100 MB became 205 MB
Act I
ArchitectureHash relationships
‣Blob‣Tree‣Commit‣Tag
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
treetree: 7e8b1 webblob: 9ab16 index.html
a10b3 treeblob: 8d162 logo.jpgblob: 51d22 draw.js
7e8b1commit
tree: a10b3parent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the web content.
c67db
blob<html>
<body></body></html>
9ab16
blob//Some more javascriptvar renderSize
51d22
blob7D 8D B3 7F BD 12 9F E97B 78 9D 3F 5C A6 72 CB
8d162
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
v1 v2 v3
committree: 9a87bparent: nilauthor: Firdcommitter: Matthewmessage:
Major refactoringof the Javascript renderingengine.
c67db
committree: b22c1parent: c67dbauthor: Timcommitter: Firdmessage:
Minor update to HTML
9bd21
committree: b22c1parent: 9bd21author: Johnnycommitter: Joemessage:
New language transations
1c2d7
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
RELEASE_1.0 HEAD
bug979branch
commitc67db
commit9bd21
commit1c2d7
commit8c2d1
commit1bdcd
commit2daa1
ArchitectureHash shortcuts
commitish & treeish
commitish = shorthand for commit hashes
treeish = shorthand for tree hashes
9AB22Fa certain commit
9AB22F^one commit before a certain commit
9AB22F^^two commits before a certain commit
9AB22F~5five commits before a certain commit
9AB223..56CD77between these two commits
HEADthe most recent commit on this branch
HEAD^one commit before the most recent commit
HEAD~2two commits before the most recent commit
HEAD..HEAD^^^between the given recent commits
masterthe most recent commit on this branch
master^^two commits before the most recent commit on this branch
master~5five commits before the most recent commit on this branch
remotes/origin/masterthe most recent commit on this remote tracking branch
origin/masterthe most recent commit on this remote tracking branch
The GraphVerification
git fsck
git verify-pack -v .git/objects/pack/FILENAME
The GraphMore graph navigation
master^{tree}find this commit’s tree
git describe HASHfind nearest tag
:/some wordscommit message that starts with
REF:FILEblob spec
:0:FILEindex
:1:FILEcommon ancestor
:2:FILEtarget
:3:FILEmerging in
@matthewmccull
github.com/training
at with Matthew McCullough
GitGraphs, Hashes, and Compression, Oh My!
© 2
012,
GitH
ub, I
nc.