2. GIT FS
"I really really designed it coming at
the problem from the viewpoint of a
filesystem person (hey, kernels is what
I do), and I actually have absolutely
zero interest in creating a traditional
SCM system."
-- Linus Torvals
4. WHY GIT? LINUX
2002 - 2005 proprietary BitKeeper
Apr 7, Linus Torvals - based on BitKeeper
concepts
May 26 - Linux 2.6.12 - the first release with Git
December 21 - Git 1.0
Msg: Initial revision of "git", the information manager
from hell
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date: Thu Apr 7 15:13:13 2005 0700
Files: catfile.c, committree.c, showdiff.c, ...
5. LINUX NEEDS
distributed, fast, many files, robust
effective storage - full history
non-linear development, trial branches, complex
merges
toolkit-based design, pluggable merge strategies
cryptographic authentication of history
6. ANNUAL LINUX DEVELOPMENT REPORT
by Linux Foundation - April 3, 2012
Linux 3.2 release - Apr 1, 2012
15,004,006 lines of code
72 days since 3.1.
11,881 patches, 6.88 per hour
1,316 developers from 226 organizations
2005-2015
12,000 developers from 1200 organizations
7. NO SILVER BULLET
permissions, ownership, empty directories, ...
individual files (not project's files)
large binary files ( )GitHub: Git LFS
complexity - commit/push, checkout/clone
no subtree of repository checkout
no sequentially revision numbers
CVS 10%, Git 38%, Subversion 46% - ohloh.net
14. THE THREE TREES 1/2
"HEAD tree" (in local repository)
HEAD - the snapshot of your last commit
index - cache, staging area
proposed next commit snapshot
working directory (working tree)
sandbox, files you see
26. GIT OBJECTS: BLOB, TREE
a blob object - content of a file
no file name, time stamps, or other metadata
a tree object - the equivalent of a directory
describes a snapshot of the source tree
names of blob and tree objects (type bits)
27. GIT OBJECTS: COMMIT
a commit object
links tree objects together into a history
the name of a tree object (of the top-level
source directory)
a time stamp, a log message
the names of zero or more parent commit
objects
28. GIT OBJECTS: TAG
a tag object
a container that contains reference to another
object
and can hold additional meta-data
50. CAT TREE (THE REAL ONE) 1/2
> git catfile t 2afe2cf674f123661ecbf68b698f1ffd4a1f5f23
tree
> git catfile p 2afe2cf674f123661ecbf68b698f1ffd4a1f5f23
100644 blob 60d6882bff469b815a3ba2334520ee7987f0bc92 .gitign
040000 tree f584e5928a3315c4dc8dcf09b46d3e4d8d711f83 dirH
100644 blob 8e4b68ee140cfbeaee5d38671cb03c83d1b6f2a4 fileA.t
100644 blob 3d67da922cae213e0ba10593c31c763543c97fee fileB.t
> git catfile t f584e5928a3315c4dc8dcf09b46d3e4d8d711f83
tree
> git catfile p f584e5928a3315c4dc8dcf09b46d3e4d8d711f83
100644 blob 7dd188dd69574eee96bc02f5783a01eceb30f8c3 fileHC.
51. CAT TREE (THE REAL ONE) 2/2
> git catfile t 7dd188dd69574eee96bc02f5783a01eceb30f8c3
blob
> git catfile p 7dd188dd69574eee96bc02f5783a01eceb30f8c3
textHC line 1
textHC line 2
52. CRYPTOGRAPHIC
the last commit - sha1
cryptographic authentication of history
commit
-> working tree -> trees + blobs
-> parent commit(s)
-> working tree(s) ...
...
the first commit (without any parent)
71. REVISIONS RANGES 2/3
<rev1>..<rev2>
include commits reachable from <rev2>
exclude commits reachable from <rev1>
<rev1>...<rev2>
include commits reachable from either <rev1>
or <rev2>
exclude reachable from both
73. GIT GREP
look for specified patterns in the tracked files
in the work tree
blobs in given tree objects
> git grep n 'line 3'
fileA.txt:3:textA line 3
> git grep n e 'line 2' HEAD~1 HEAD~2
HEAD~1:fileB.txt:2:textB line 2
74. GIT GREP --CACHED
look for specified patterns in the tracked files
blobs registered in the index file
> git grep n cached 'line 3'
> git grep n cached 'line 2'
dirH/fileHC.txt:2:textHC line 2
fileA.txt:2:textA line 2
fileB.txt:2:textB line 2
75. GIT LOG -- <PATHS>
commits modifying the given are selected
gitk -- <string>
> git log oneline dirH
e4d63af commit 04 message
fcb9538 commit 03 message
76. GIT LOG -S <STRING> 1/2
... introduce or remove an instance of <string>
gitk -S <string>
86. GIT CHECKOUT <BRANCH>
move only HEAD (switch branch)
reset index
reset not modified files
merge modified
reset working tree
reset not modified files
merge modified
87. GIT CHECKOUT BRC2 1/2
> git branch v
BRc2 ec23b35 commit 02 message
* master e4d63af commit 04 message
mjtest e4d63af commit 04 message
> git reset hard master
HEAD is now at e4d63af commit 04 message
> cat fileA.txt
textA line 1
> echo "textA line 2" >> fileA.txt
> git add A
> echo "textA line 3" >> fileA.txt
88. GIT CHECKOUT BRC2 2/2
> git checkout BRc2
Switched to branch 'BRc2'
M fileA.txt
> git status short
MM fileA.txt
> git diff cached | grep '+textA'
+textA line 2
> git diff | grep '+textA'
+textA line 3
96. GITHUB
a web-based hosting service
3.7M people, 7.1M repositories
investment - July 2012, $100 million USD
a pastebin-style site called Gist
private
US$7/month for five repositories
up to US$200/month for 125 repositories
Bitbucket, Gitorious, SourceForge, CodePlex,
Google Code, Launchpad
June 2013
A16Z
114. LINKS
Pro Git, Scott Chacon
license
- Czech translation
git-scm.com
CC BY 3.0
knihy.nic.cz
git-cheatsheet
115. THANK YOU
Michal Jurosz (mj41)
www.GoodData.com
Generated from source
by inside .
Powered by .
github.com/mj41/git-course-mj41
Presentation::Builder prbuilder Docker container
reveal.js