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
29
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
29
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.
35
76. Remote
is like a special
Stash
Repo
Index
Working
77. Remote
is like a special
Stash
Repo
Index
Working
78. Remote
is like a special
Stash
Repo
git clone
Index
Working
79. Remote
is like a special
Stash
Repo
git clone
git checkout
Index
Working
80. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
Index
Working
81. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
Index
Working
82. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index
Working
83. Remote
is like a special
Stash
Repo
git clone
git checkout
edit some files
git stash
edit some files
Index git stash apply
Working
84. 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
85. 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
86. 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
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 git add
git commit
git push
88. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
38
89. repo
uild
B
git clone git://somedomain/myproj.git
cd myproj.git
dex
te in
pda
U
git checkout master
38
90. 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
38
91. 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
38
92. 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
38
93. Single Stage Thinking
Subversion
svn commit
‣
‣ Adds everything modified.
‣ Must list if you want specific files.
‣ What if you check in your password?
39
95. $ echo //password >> Matt1.java
$ echo //password >> Matt2.java
$ svn status
M Matt1.java
M Matt2.java
40
96. $ 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.
40
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.
41
99. $ echo //SECRETPASSWORD >> mattfile1.java
$ echo //NewText2 >> mattfile2.java
$ git status
# On branch master
# Changed but not updated:
# modified: mattfile1.txt
# modified: mattfile2.txt
42
100. $ echo //SECRETPASSWORD >> mattfile1.java
$ echo //NewText2 >> mattfile2.java
$ git status
# On branch master
# Changed but not updated:
# modified: mattfile1.txt
# modified: mattfile2.txt
dex
o in
int
Put
$ git add mattfile1.txt
42
101. $ echo //SECRETPASSWORD >> mattfile1.java
$ echo //NewText2 >> mattfile2.java
$ 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(-)
42
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
44
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
44
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
44
149. Serving It Up
Filesystem
‣ Local folders. Yes, they can be “remotes.”
‣ Mapped network drives. Just like folders.
62
150. on
aem
it d
g
git clone git://somehost.org/myproj.git
63
151. on
aem
it d
g
git clone git://somehost.org/myproj.git
SSH
git clone mccm06@somehost.org:myproj.git
63
152. 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
63
153. 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
63
154. 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
63
166. Cherry Pick
❻
‣git cherry-pick a5b2ee
‣Merge in just one commit.
73
167. Cherry Pick
❻
‣git cherry-pick a5b2ee
‣Merge in just one commit.
‣When you want a nugget, not a branchload.
73
168. Gives Credit
❺
‣Tracks who authors a change.
74
169. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
74
170. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
‣“Author” survives all merges.
74
171. Gives Credit
❺
‣Tracks who authors a change.
‣“Author” even survives passing through reviewers.
‣“Author” survives all merges.
‣Additionally tracks who committed a change.
74
184. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
78
185. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
‣Makes for simpler merge graphs.
78
186. Rebase
❶
‣git rebase master
‣Reposition your feature branch’s start point.
‣Makes for simpler merge graphs.
‣Sustains feature-branch work clarity.
78
189. 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
81