An updated introduction to the Git Distributed Version Control System. Be prepared to have everything you know about centralized VCS systems turned upside down, but all for the benefit of easy of use, better team-mate interactions, and more robust (guaranteed) repository integrity and uptime.
47. SHA-1 Hash
Index vs. Hash
‣ Centralized VCS uses DB auto-increment index.
‣ Git uses SHA-1 hash.
‣ Hash for the sake of integrity.
Hashable Objects
‣ Blob
‣ Tree
‣ Commit
‣ Tag
48. SHA-1 Hash
Index vs. Hash
‣ Centralized VCS uses DB auto-increment index.
‣ Git uses SHA-1 hash.
‣ Hash for the sake of integrity.
Hashable Objects ght
hou
It ere
‣ Blob es w
ash
h
‣ Tree
for
rds?
‣ Commit
swo
pas
‣ Tag
74. Hash Benefits
Integrity
‣ Identifies damaged repos.
‣ Prevents modification of published history.
‣ Unique to file size and contents.
Tags
‣ Cryptographically sign tags by GPG/email.
Independence
‣ Separation from sequence # of checkin.
76. Single Stage Thinking
Subversion
svn commit
‣
‣ Adds everything modified.
‣ Must list if you want specific files.
‣ What if you check in your password?
78. $ echo //password >> Matt1.java
$ echo //password >> Matt2.java
$ svn status
M Matt1.java
M Matt2.java
79. $ echo //password >> Matt1.java
$ echo //password >> Matt2.java
$ svn status
M Matt1.java
M Matt2.java
$ svn commit -m'Matts checkin'
Adding Matt1.java
Adding Matt2.java
Transmitting file data .
Committed revision 2.
80. Remote
is like a special
Stash
Repo
Index
Working
81. Remote
is like a special
Stash
Repo
Index
Working
82. Remote
is like a special
Stash
Repo
git clone
Index
Working
83. Remote
is like a special
Stash
Repo
git clone
git checkout
Index
Working
84. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
Index
Working
85. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
Index
Working
86. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index
Working
87. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working
88. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working git add
89. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working git add
git commit
90. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working git add
git commit
git push
91. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working git add
git commit
git push
92. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
93. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
dex
te in
pda
U
git checkout master
94. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
dex
te in
pda
U
git checkout master
king
echo ‘//Comments’ >> ClassOne.java or
dit w
echo ‘//Thoughts’ >> ClassTwo.java E
95. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
dex
te in
pda
U
git checkout master
king
echo ‘//Comments’ >> ClassOne.java or
dit w
echo ‘//Thoughts’ >> ClassTwo.java E
ndex
to i
Add epo
git add ClassOne.java to r
ave
comments’ S
git commit -m’Added
96. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
dex
te in
pda
U
git checkout master
king
echo ‘//Comments’ >> ClassOne.java or
dit w
echo ‘//Thoughts’ >> ClassTwo.java E
ndex
to i
Add epo
git add ClassOne.java to r
ave
commit -m’Added comments’ S
git
ash
st
h to
stash Pus
git
97. Three Stage Thinking
Git
git add
‣
git commit
‣
git push
‣
‣ Commits only what is added to the index.
‣ Opportunity to change history locally.
‣ Selectively share with other repos.
99. $ echo //SECRETPASSWORD >> mattfile1.txt
$ echo //NewText2 >> mattfile2.txt
$ git status
# On branch master
# Changed but not updated:
# modified: mattfile1.txt
# modified: mattfile2.txt
100. $ echo //SECRETPASSWORD >> mattfile1.txt
$ echo //NewText2 >> mattfile2.txt
$ git status
# On branch master
# Changed but not updated:
# modified: mattfile1.txt
# modified: mattfile2.txt
dex
o in
int
Put
$ git add mattfile1.txt
101. $ echo //SECRETPASSWORD >> mattfile1.txt
$ echo //NewText2 >> mattfile2.txt
$ git status
# On branch master
# Changed but not updated:
# modified: mattfile1.txt
# modified: mattfile2.txt
dex
o in
int
Put
$ git add mattfile1.txt
epo
to r
ave
S
$ git commit -m'Matts pw checkin'
[master]: created ddcdf18: quot;Matts changesquot;
1 files changed, 1 insertions(+), 0 deletions(-)
103. Change History
$ git reset --hard HEAD^
HEAD is now at 9de4cd3 First checkin
$ git log
commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993
Author: Matthew McCullough
<matthewm@ambientideas.com>
Date: Wed Mar 4 23:09:17 2009 -0700
First checkin
104. Change History
mit
com
the
way
wa
hro
T
$ git reset --hard HEAD^
HEAD is now at 9de4cd3 First checkin
$ git log
commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993
Author: Matthew McCullough
<matthewm@ambientideas.com>
Date: Wed Mar 4 23:09:17 2009 -0700
First checkin
105. Change History
mit
com
the
way
wa
hro
T
$ git reset --hard HEAD^
HEAD is now at 9de4cd3 First checkin
$ git log
commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993
Author: Matthew McCullough
<matthewm@ambientideas.com>
Date: Wed Mar 4 23:09:17 2009 -0700
First checkin
114. Serving It Up
Network
‣ git instaweb. Built in, read-only, HTTP.
‣ git daemon. Custom socket language.
‣ gitosis. Easy permissions control.
‣ github. Open source & private repos.
‣ ssh. OS controlled permissions.
115.
116.
117. Serving It Up
Filesystem
‣ Local folders. Yes, they can be “remotes.”
‣ Mapped network drives. Just like folders.
118. on
aem
it d
g
git clone git://somehost.org/myproj.git
119. on
aem
it d
g
git clone git://somehost.org/myproj.git
SSH
git clone mccm06@somehost.org:myproj.git
120. on
aem
it d
g
git clone git://somehost.org/myproj.git
SSH
git clone mccm06@somehost.org:myproj.git
TTP
H
git clone http://somehost.org/myproj.git
121. on
aem
it d
g
git clone git://somehost.org/myproj.git
SSH
git clone mccm06@somehost.org:myproj.git
TTP
H
git clone http://somehost.org/myproj.git
tem
sys
File
git clone ~/work/myproj.git
122. on
aem
it d
g
git clone git://somehost.org/myproj.git
SSH
git clone mccm06@somehost.org:myproj.git
TTP
H
git clone http://somehost.org/myproj.git
tem
sys
File
git clone ~/work/myproj.git
rive
rk d
two
Ne
git clone z:someservermyproj.git
130. Rebase for Clarity
git checkout myfeaturebranch
git rebase master
‣Cleaner history than a merge
‣Fast forwards original branch
‣Lets you see “how trunk will act” before you merge
177. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
178. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
‣“Author” survives all merges.
179. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
‣“Author” survives all merges.
‣Additionally tracks who committed a change.
185. Squash Verbosity
❸
‣git merge --squash mybranch
‣Reduce all your micro-checkins to block commits.
186. Squash Verbosity
❸
‣git merge --squash mybranch
‣Reduce all your micro-checkins to block commits.
‣Make mistakes, revise, checkin without hesitation.
187. Squash Verbosity
❸
‣git merge --squash mybranch
‣Reduce all your micro-checkins to block commits.
‣Make mistakes, revise, checkin without hesitation.
‣Great for SVN compatibility.
192. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
193. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
‣Makes for simpler merge graphs.
194. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
‣Makes for simpler merge graphs.
‣Sustains feature-branch work clarity.
197. tthew
Ma
Twitter
@matthewmccull
Blog
http://www.ambientideas.com/blog
sidebar has all my social media links
Email
matthewm@ambientideas.com
GitHub
http://github.com/matthewmccullough