Professional Documents
Culture Documents
Git Foundations
An exploration of the Git toolbox
Hello!
cCullough
atthew M
M
mccull
@matthew
Ma hew who?
Open source contributor
Build tool book co-author
Continuous integration book co-author
5 year Git evangelist
VP of Training at GitHub
Questions, Pacing
Welcome
Git
Wheres this coming from?
Git
Open Source
Git?
bash scripts
C code
Git?
Git?
Git
-noun
asa nt
unple
ng. an
ritish Sla
B
er son
tible p
temp
r con
o
Dictionar y
ord English
-Oxf
name
myself.
ts after
y projec
all m
astard, and I
egotistical b
I'm an
st Linux, now
Fir
git.
inus Torvalds
-L
Git
What is this thing?
cker
upid content tra
GIT - the st
r mood.
depending on you
nything,
any
"git" can mean a
actually used by
t
le, and no
ay not be
t is pronounceab
bination tha
f "get" may or m
etter com
ciation o
* random three-l
t is a mispronun
ct that i
command. The fa
ary of
common UNIX
from the diction
our pick
relevant.
. simple. Take y
espicable
ntemptible and d
or you.
* stupid. co
actually works f
, and it
slang.
e in a good mood
e r" : y o u ' r
nformation track
he room.
* "global i
suddenly fills t
a light
breaks
Angels sing, and
f sh*t": when it
uckload o
ddamn idiotic tr
rich
* "go
ith an unusually
system w
als.
revision control
distributed
access to intern
calable,
and full
Git is a fast, s
level operations
th highthat provides bo
inally
command set
nse. It was orig
blic Lice
ntly
e GNU General Pu
net. It is curre
covered by th
project
round the
oup of hackers a
s an Open Source
Git i
lp of a gr
Torvalds with he
written by Linus
C Hamano.
tained by Junio
main
content tracker
le
Git?
Subversion
Perforce
Source
Safe
PVCS
Clear
Case
CVS
RCS
Folders
Git?
radical innovation
Git?
Linus?
Git?
a commercial
for 7 years at
up using CVS
I did end
ith a passion...
y and I hate it w
compan
or a while was
of Subversion f
The slogan
tart with that
"... and if you s
done right
"CVS
e you can go.
, there's nowher
kind of slogan
o CVS right.
no way to d
There is
-Linus Torvalds
VCS reboot
Git?
with
50% Git Concepts
Git?
1997
code co-op
2001
arch
2003
monotone
2003
SVK
2003
darcs
2005
bazaar
2005
mercurial
2005
git
time to mature
Setup
Testing Git
Setting up Git
Setup
What is a Git install?
Setting up Git
Using
Creating a repository
#
$
$
#
Creating A Repository
Creating A Repository
Creating A Repository
Using
Whats in .git?
.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
Contents of .git
Conguration
Display
Conguring Git
All entries
Conguring Git
Conguring Git
Single entry
Conguring Git
Conguring Git
Conguring Git
Conguration
Layers
Cong Targets
Cong Targets
Cong Targets
targets
local by default
Cong Targets
Conguration
Inheritance
Cong Inheritance
Cong Inheritance
Cong Inheritance
Cong Inheritance
Cong Inheritance
Cong Inheritance
Conguration
Set user identity
just a string
Set User Identity
user identity
identity
not user authentication
authorization
identity
not user authentication
Conguration
Display color
console color
git log \
--graph \
--decorate \
--simplify-by-decoration \
--abbrev-commit \
--date=relative \
--pretty=oneline \
--all
git log \
--graph \
--decorate \
--simplify-by-decoration \
--abbrev-commit \
--date=relative \
--pretty=oneline \
--all \
| more
Conguring Git
Bleh!
Set Console Color
git log \
--graph \
--decorate \
--simplify-by-decoration \
--abbrev-commit \
--date=relative \
--pretty=oneline \
--all \
| more
Set Console Color
Conguration
Line endings
line endings
Line Endings
VS
Line Endings
LF
VS
CRLF
Line Endings
default is to do
nothing
Line Endings
http://help.github.com/dealing-with-lineendings/
Line Endings
Line Endings
Line Endings
Line Endings
Conguration
Secure Sockets Host (SSH)
Conguring SSH
Conguring SSH
Conguring SSH
Conguring SSH
Conguring SSH
Conguring SSH
Conguring SSH
Conguring SSH
Using Git
Three Stage Thinking
Edit
Add
Commit
Three stage thinking
Working
Staging
Repo
edit
add
commit
Three stage thinking
shopping cart
put things in
take things out
purchase at register
database transaction
update values
insert rows
delete rows
commit transaction
only
Working
Staging
Repo
edit
add
commit
Three stage thinking
Setup
Commit Message Editor
I
y
;WQ
Commit Message Editor
an alternate editor?
O
n
io
pt
O
n
io
pt
1
$ export EDITOR=<AnEditorOnYourPath>
O
n
io
pt
2
GitPad wraps Notepad (or $EDITOR)
O
n
io
pt
http://github.com/github/GitPad
O
n
io
pt
2
Run GitPad
...registers & wraps Notepad as the editor
O
n
io
pt
O
n
io
pt
3
#for Notepad2 on Windows
git config --global core.editor "notepad2.exe"
O
n
io
pt
3
Commit Message Editor
Make a commit
Usage Basics
Adding & committing code
$ vi first.html
$ git status
$ git add first.html
$ git commit -mFirst commit
Three stage thinking
Inspect Gits status
Commit code
Usage Basics
Diff-ing changes
Working
Staging
Repo
$ git diff
Three stage thinking
Working
Staging
Repo
Working
Staging
Repo
Usage Basics
Limiting diff output
$ git diff
diff --git a/first.txt b/first.txt
index cbb1543..e99dea9 100644
--- a/first.txt
+++ b/first.txt
@@ -1,4 +1,4 @@
-//Round the rugged rock
+//Round the ragged rock
$ git diff --color-words
diff --git a/first.txt b/first.txt
index cbb1543..e99dea9 100644
--- a/first.txt
+++ b/first.txt
@@ -1,4 +1,4 @@
//Round the ruggedragged rock
Limiting Diff Output
$ git diff
diff --git a/first.txt b/first.txt
index cbb1543..e99dea9 100644
--- a/first.txt
+++ b/first.txt
@@ -1,4 +1,4 @@
-//Round the rugged rock
+//Round the ragged rock
$ git diff --word-diff
diff --git a/first.txt b/first.txt
index cbb1543..e99dea9 100644
--- a/first.txt
+++ b/first.txt
@@ -1,4 +1,4 @@
//Round the [-rugged-]{+ragged+} rock
Limiting Diff Output
Usage Basics
Whitespace diff
whitespace suppressed?
refactoring review
Limiting Diff Output
git diff -w
Limiting Diff Output
$ git diff
diff --git a/first.txt b/first.txt
index 09195c0..f2c3243 100644
--- a/first.txt
+++ b/first.txt
@@ -1,4 +1,4 @@
-//Foo
-//Bar
-//Baz
+ //Foo
+//
Bar
+//Baz
$ git diff -w
$
Limiting Diff Output
Usage Basics
Limiting diff by type
#
#
#
#
#
#
#
#
#
Added (A)
Copied (C)
Deleted (D)
Modified (M)
Renamed (R)
Type changed (T)
Unmerged (U)
Unknown (X)
Pairing Broken (B)
#
#
#
#
#
#
#
#
#
Added (A)
Copied (C)
Deleted (D)
Modified (M)
Renamed (R)
Type changed (T)
Unmerged (U)
Unknown (X)
Pairing Broken (B)
#
#
#
#
#
#
#
#
#
Added (A)
Copied (C)
Deleted (D)
Modified (M)
Renamed (R)
Type changed (T)
Unmerged (U)
Unknown (X)
Pairing Broken (B)
$ git status -s -u
D README
MM first.txt
$ git diff --diff-filter=M
diff --git a/first.txt b/first.txt
index 71b55ef..14e4853 100644
--- a/first.txt
+++ b/first.txt
@@ -1,3 +1,3 @@
-//Foo
Only rst.txt is
//Bar
reported
+//Baz
Usage Basics
Reviewing history
# Limit
git log
git log
git log
Usage Basics+
Ignoring les
Ignored
Untracked
Tracked
Unmodied
Tracked
Modied
Tracked
Staged
ignore
add
edit
add
commit
rm
Ignoring Files
Ignoring Files
glob patterns
Ignoring Files
$ vim .gitignore
#Add glob patterns, one per line
*.log
*.tmp
Ignoring Files
Ignoring Files
$ vim .gitignore
#Add glob patterns, one per line
*.log
*.tmp
target
output/
!special.log
Ignoring Files
Ignoring Files
Usage Basics+
Open source .gitignores
http://github.com/github/gitignore
Open Source Ignores
Usage Basics+
Global ignores
Global .gitignore ?
Global Ignore
off by default
Global Ignore
Global Ignore
$ vim ~/.gitignore
Global Ignore
Global Ignore
Usage Basics+
Removing les
Ignored
Untracked
Tracked
Unmodied
Tracked
Modied
Tracked
Staged
ignore
add
edit
add
commit
rm
Removing Files
Remove les
Usage Basics+
Moving les
Ignored
Untracked
Tracked
Unmodied
Tracked
Modied
Tracked
Staged
ignore
add
edit
add
commit
rm
Moving Files
Usage Basics+
Similarity index
no "move" primitive
Similarity Index
similarity index
Similarity Index
score of
sameness
Similarity Index
Usage Basics+
Similarity index for moves
# Renames shown
git log --stat -M
Similarity Index
Similarity Index
Usage Basics+
Similarity index for copies
Similarity Index
Similarity Index
asons, by
mance re
r perfor
Fo
on finds
, -C opti
default
iginal file
f the or
ies only i
cop
dified in
y was mo
the cop
of
angeset.
same ch
the
Similarity Index
makes the
-harder flag
find-copies
The -ified files as
pect unmod
command ins
copy. This
source of
ates for the
candid
for large
ive operation
a very expens
is
ion. Giving
it with caut
ts, so use
projec
as the same
-C option h
re than one
mo
effect.
Similarity Index
Similarity Index
Usage Basics+
Similarity index for blame
Similarity Index
Similarity Index
5b2fd956
c455c87c
5b2fd956
5b2fd956
dea4562b
dea4562b
dea4562b
8588567c
5b2fd956
ac49f5ca
ac49f5ca
ac49f5ca
ac49f5ca
ac49f5ca
5b2fd956
5b2fd956
5b2fd956
5b2fd956
5b2fd956
5b2fd956
5b2fd956
5b2fd956
90056966
5b2fd956
90056966
5b2fd956
5b2fd956
(Stephan Beyer
(Johannes Schindelin
(Stephan Beyer
(Stephan Beyer
(Junio C Hamano
(Junio C Hamano
(Junio C Hamano
(Junio C Hamano
(Stephan Beyer
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(Stephan Beyer
(SZEDER Gbor
(Stephan Beyer
(SZEDER Gbor
(Stephan Beyer
(Stephan Beyer
2008-07-09
2008-07-21
2008-07-09
2008-07-09
2009-12-25
2009-12-25
2009-12-25
2010-01-16
2008-07-09
2011-02-16
2011-02-16
2011-02-16
2011-02-16
2011-02-16
2008-07-09
2008-07-09
2008-07-09
2008-07-09
2008-07-09
2008-07-09
2008-07-09
2008-07-09
2009-02-14
2008-07-09
2009-02-14
2008-07-09
2008-07-09
14:58:57
19:03:49
14:58:57
14:58:57
15:51:32
15:51:32
15:51:32
23:28:46
14:58:57
05:47:44
05:47:44
05:47:44
05:47:44
05:47:44
14:58:57
14:58:57
14:58:57
14:58:57
14:58:57
14:58:57
14:58:57
14:58:57
23:21:04
14:58:57
23:21:04
14:58:57
14:58:57
+0200
+0100
+0200
+0200
-0800
-0800
-0800
-0800
+0200
-0500
-0500
-0500
-0500
-0500
+0200
+0200
+0200
+0200
+0200
+0200
+0200
+0200
+0100
+0200
+0100
+0200
+0200
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
#include
#include
#include
#include
#include
#include
#include
#include
"cache.h"
"string-list.h"
"rerere.h"
"xdiff-interface.h"
"dir.h"
"resolve-undo.h"
"ll-merge.h"
"attr.h"
#define RESOLVED 0
#define PUNTED 1
#define THREE_STAGED 2
void *RERERE_RESOLVED = &RERERE_RESOLVED;
/* if rerere_enabled == -1, fall back to detection of .git
static int rerere_enabled = -1;
/* automatically update cleanly resolved paths to the inde
static int rerere_autoupdate;
static char *merge_rr_path;
const char *rerere_path(const char *hex, const char *file)
{
return git_path("rr-cache/%s/%s", hex, file);
}
Similarity Index
5b2fd956
c455c87c
5b2fd956
5b2fd956
dea4562b
dea4562b
dea4562b
8588567c
5b2fd956
ac49f5ca
ac49f5ca
ac49f5ca
ac49f5ca
ac49f5ca
b4372ef1
b4372ef1
b4372ef1
121c813f
121c813f
121c813f
658f3650
658f3650
90056966
5b2fd956
90056966
5b2fd956
5b2fd956
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
builtin-rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
rerere.c
(Stephan Beyer
(Johannes Schindelin
(Stephan Beyer
(Stephan Beyer
(Junio C Hamano
(Junio C Hamano
(Junio C Hamano
(Junio C Hamano
(Stephan Beyer
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Martin von Zweigbergk
(Johannes Schindelin
(Johannes Schindelin
(Johannes Schindelin
(Junio C Hamano
(Junio C Hamano
(Junio C Hamano
(Johannes Schindelin
(Johannes Schindelin
(SZEDER Gbor
(Stephan Beyer
(SZEDER Gbor
(Stephan Beyer
(Stephan Beyer
2008-07-09
2008-07-21
2008-07-09
2008-07-09
2009-12-25
2009-12-25
2009-12-25
2010-01-16
2008-07-09
2011-02-16
2011-02-16
2011-02-16
2011-02-16
2011-02-16
2007-07-06
2007-07-06
2007-07-06
2008-06-22
2008-06-22
2008-06-22
2006-12-20
2006-12-20
2009-02-14
2008-07-09
2009-02-14
2008-07-09
2008-07-09
14:58:57
19:03:49
14:58:57
14:58:57
15:51:32
15:51:32
15:51:32
23:28:46
14:58:57
05:47:44
05:47:44
05:47:44
05:47:44
05:47:44
13:05:59
13:05:59
13:05:59
02:04:31
02:04:31
02:04:31
17:39:41
17:39:41
23:21:04
14:58:57
23:21:04
14:58:57
14:58:57
+0200
+0100
+0200
+0200
-0800
-0800
-0800
-0800
+0200
-0500
-0500
-0500
-0500
-0500
+0100
+0100
+0100
-0700
-0700
-0700
+0100
+0100
+0100
+0200
+0100
+0200
+0200
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
#include
#include
#include
#include
#include
#include
#include
#include
"cache.h"
"string-list.h"
"rerere.h"
"xdiff-interface.h"
"dir.h"
"resolve-undo.h"
"ll-merge.h"
"attr.h"
#define RESOLVED 0
#define PUNTED 1
#define THREE_STAGED 2
void *RERERE_RESOLVED = &RERERE_RESOLVED;
/* if rerere_enabled == -1, fall back to detection of .git
static int rerere_enabled = -1;
/* automatically update cleanly resolved paths to the inde
static int rerere_autoupdate;
static char *merge_rr_path;
const char *rerere_path(const char *hex, const char *file)
{
return git_path("rr-cache/%s/%s", hex, file);
}
Similarity Index
Network
Ofine design
nice benet,
but wrong reason
Ofine
Ofine
Ofine
Checkout a branch
Add changes
Commit changes
Branch changes
Log history
Grep history
Stash pending changes
Tag a commit
Remove a le
Merge a branch
Rewrite history
Ofine
Ofine
Ofine
Network
Cloning protocols
le
git
ssh
http
Cloning Repositories
le
Cloning Repositories
git
Cloning Repositories
ssh
git
git
clone git+ssh://user@server:project.git
clone user@server:project.git
Cloning Repositories
http (dumb)
git
git
clone http://server/project.git
clone https://server/project.git
Cloning Repositories
http (smart)
git
git
clone http://server/project.git
clone https://server/project.git
Cloning Repositories
Clone hellogitworld
git clone
Cloning Repositories
Network
Proxy servers
Git Conguration
git
Cloning Repositories
Network
Speed
hg: mercurial
bzr: bazaar
git: git
Init
Status
Diff
Branch
git
svn
git
Tag
Log
svn
Commit (Lg)
git
svn
Commit (Sm)
git c
git
svn
git
svn
git
svn
git
svn c
svn
Speed
Speed
Network
Namespaces
Local
Remote
Upstream
Namespaces
Namespaces
Local
Remote
Upstream
Namespaces
Namespaces
Local
Remote
Upstream
Namespaces
Namespaces
Local
Remote
Upstream
Namespaces
Namespaces
Local
Remote
Upstream
Namespaces
Network
Namespace operations
Local
clone
Remote
clone
Upstream
clone
commit
push
push
fetch
pull
pull
pull
Namespaces
Network
The commit lifecycle
ll
Pu
Pu
sh
Commit
Namespaces
git
commit
Namespaces
ll
Pu
Pu
sh
Commit
Namespaces
Namespaces
ll
Pu
Pu
sh
Commit
Namespaces
git
pull <remote>
Local
clone
Remote
clone
Upstream
clone
commit
push
push
fetch
pull
pull
pull
Namespaces
Network
Remotes
Remotes
Remotes
Remotes
Remotes
Local
Remote
Upstream
Remotes
Adding remotes
Fetching from remotes (upstream)
Remotes
Network
Pruning deletions
git
Pruning locally
Remotes
Architecture
Plumbing and Porcelain
Command Composition
Command Composition
Command Composition
Command Composition
Command Composition
Porcelain
Plumbing
git-add git-am git-archive git-bisect git-branch git-bundle gitcheckout git-cherry-pick git-citool git-clean git-clone git-commit
git-describe git-diff git-fetch git-format-patch git-gc git-grep gitgui git-init git-log git-merge git-mv git-notes git-pull git-push gitrebase git-reset git-revert git-rm git-shortlog git-show git-stash
git-status git-submodule git-tag gitk git-config git-fast-export gitfast-import git-filter-branch git-lost-found git-mergetool git-packrefs git-prune git-reflog git-relink git-remote git-repack git-replace
git-repo-config git-annotate git-blame git-cherry git-count-objects
git-difftool git-fsck git-get-tar-commit-id git-help git-instaweb gitmerge-tree git-rerere git-rev-parse git-show-branch git-verify-tag
git-whatchanged git-archimport git-cvsexportcommit git-cvsimport gitcvsserver git-imap-send git-quiltimport git-request-pull git-sendemail git-svn
Command Composition
Command Composition
Command Composition
Aliases
Command shortcuts
Create your own recipe
Aliases
Aliases
Add an alias
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Matthew's Aliases
https://github.com/matthewmccullough/git-workshop/blob/master/
workbook/examples/cong/.gitcong
Aliases
Architecture
Storage
Storage
Storage
v1
v2
File C
File B
v4
v5
File A
File A
File B
v3
File A
File B
File B
File B
File C
Storage
eck
in
kin
Ch
Checkin
ckin
he
Chec
kin
ec
h
in
k
ec
h
k
in
C
h
ec
C
hec
kin
kin
e
of ha cle
C
gets
Checkin
Storage
Checkin
Storage
Storage
Storage
Storage
cp -r srcfolder srcfolder.prev
Storage
Why?
Storage
v1
v2
v3
v4
v5
File A
File A
File A
File A
File A
File B
File B
File B
File B
File B
File C
File C
File C
File C
File C
Storage
Storage
v1
v2
v3
v4
v5
File A
File A
File A
File A
File A
File B
File B
File B
File B
File B
File C
File C
File C
File C
File C
Storage
Storage
v1
v2
v3
v4
v5
File A
File A
File A
File A
File A
File B
File B
File B
File B
File B
File C
File C
File C
File C
File C
Storage
Storage
v1
v2
v3
v4
v5
File A
File A
File A
File A
File A
File B
File B
File B
File B
File B
File C
File C
File C
File C
File C
Storage
Act I
2100 MB became
205 MB
Storage
Architecture
Hashes
Hashes
Hashes
Hashes
40 hex characters
(20 bytes)
Hashes
9AB223D28B1AA46EF1780B22F304982E39872C34
Hashes
<html>
<body>
<p>This is a test</p>
<img src="http://ai.com/icon.gif">
</body>
</html>
9AB223D28B1AA46EF1780B22F304982E39872C34
9AB223D28B1AA46EF1780B22F304982E39872C34
Hashes
Hashes
Architecture
Hash shortcuts
Hashes
commitish
Hashes
treeish
Hashes
9AB22F
a certain commit
Hashes
9AB22F^
one commit before a certain commit
Hashes
9AB22F^^
two commits before a certain commit
Hashes
9AB22F~5
ve commits before a certain commit
Hashes
9AB223..56CD77
between these two commits
Hashes
HEAD
the most recent commit on this branch
Hashes
HEAD^
one commit before the most recent commit
Hashes
HEAD~2
two commits before the most recent commit
Hashes
HEAD..HEAD^^^
between the given recent commits
Hashes
master
the most recent commit on this branch
Hashes
master^^
two commits before the most recent commit on this branch
Hashes
master~5
ve commits before the most recent commit on this branch
Hashes
remotes/origin/master
the most recent commit on this remote tracking branch
Hashes
origin/master
the most recent commit on this remote tracking branch
Hashes
Hashes
Architecture
Hash relationships
Blob
Tree
Commit
Tag
Hashes
8d162
blob
c67db
commit
7e8b1
a10b3
tree:
parent:
author:
committer:
message:
a10b3
nil
Fird
Matthew
Major refactoring
of the web content.
tree:
blob:
tree
7e8b1 web
9ab16 index.html
blob:
blob:
tree
8d162 logo.jpg
51d22 draw.js
9ab16
7D 8D B3 7F BD 12 9F E9
7B 78 9D 3F 5C A6 72 CB
51d22
blob
blob
<html>
<body></body>
</html>
Hashes
v1
c67db
commit
tree:
parent:
author:
committer:
message:
9a87b
nil
Fird
Matthew
Major refactoring
of the Javascript rendering
engine.
v2
9bd21
commit
tree:
parent:
author:
committer:
message:
b22c1
c67db
Tim
Fird
v3
1c2d7
commit
tree:
parent:
author:
committer:
message:
b22c1
9bd21
Johnny
Joe
Hashes
c67db
commit
9bd21
commit
1c2d7
commit
8c2d1
commit
HEAD
RELEASE_1.0
1bdcd
commit
2daa1
commit
bug979branch
Hashes
Branching
Creating branches
Branches
Branches
Local
Remote
Upstream
Branches
# Creating a branch
git branch <BRANCHNAME>
Branches
c67db
commit
9bd21
commit
1c2d7
commit
8c2d1
commit
HEAD
RELEASE_1.0
1bdcd
commit
2daa1
commit
bug979branch
Hashes
# Creating a branch
git branch <BRANCHNAME> HEAD
Branches
# Creating a branch
git branch <BRANCHNAME> <REF>
Branches
c67db
commit
9bd21
commit
1c2d7
commit
8c2d1
commit
HEAD
RELEASE_1.0
1bdcd
commit
2daa1
commit
bug979branch
Hashes
Branching
Branch as experiments
Branches
Experimentation
Branches
Safe experimentation
Experimentation
Branches
Branches
Hashes
Branching
Branch frequency
Branches
Branches
Branches
Branches
Branches
Hashes
Branching
Branch lifetimes
Branched by lifetime
Product
Integration
Feature
Story
Idea
Branches
product
integration
feature
story
idea
Branches
product
v1.0 integration
story1
story2
v1.5 integration
story3
Branches
Local
Remote
Upstream
Integ
Integ
Integ
Product
Product
Product
Branches
Local
Remote
Upstream
Feature
Feature
Feature
Integ
Integ
Integ
Product
Product
Product
Idea
Story
Branches
Local
Remote
Upstream
Feature
Feature
Feature
Integ
Integ
Integ
Product
Product
Product
Idea
Story
Branches
Branching
Stashes
Stash
local-only branch
Stash
Stack based implementation
Numbered branch
Stash
creating a stash
Stash
git stash
Stash
Stash
Stash
Stash
Stash
Stash
Stash
converting a stash
Stash
Stash
Stash
Branches
Tagging
Tag uses
Dev
CM
QA
Production
Tagging
Tagging
Tag types
reference,
annotated and
signed tag types
Tagging
Tagging
Reference tag
reference tag...
Tagging
# Tag HEAD
git tag <TAGNAME>
Tagging
Tagging
Tagging
Tagging
Tag a revision
Start a branch from a tag
Tagging
Tagging
Annotated tag
annotated tag...
Tagging
Tagging
Tagging
Tagging
Tagging
Signed tag
signed tag...
Tagging
Tagging
Tagging
Tagging
Tagging
Transmitting tags
Tags don't
push by default
Tagging
Tagging
Tagging
Tags do
fetch by default
Tagging
Tagging
Merging
The basics
Merging
Merging
a32
Master/Trunk/MainLatest
e
iv
s
r
u e
c g
e r
R e
M
Bra
nch
d19
2e2
e69
8b3
8b3
e69
9f1
ge
er
M
Merging
strategy: recursive
result: no conicts
a32
Master/Trunk/MainLatest
d
r
a
w
r
o
F
t rge
s e
a
F M
Bra
nch
d19
e69
ge
er
M
Merging
Master/Trunk/MainLatest
F
F e
g
r
e
M
a32
d19
e69
Merging
strategy: recursive
result: fast forward
Bra
nch
a32
Master/Trunk/MainLatest
g
in
t
ic
l
f
n ge
o
r
C
e
M
d19
2e2
e69
8b3
8b3
Fix Conict
e69
9f1
ge
er
M
Merging
strategy: recursive
result: conicting
Merging
Octopus
Merging
strategy: octopus
Merging
Subtree
Merging
Merging
strategy: subtree
Merge a remote branch
Tagging
Rebasing
What is rebasing?
Rebasing
Rebasing
Rebasing
Rebasing
Rebasing
Rebasing
Rebasing on a branch
Rebasing
Rebasing
Rebasing
a32
Master/Trunk/MainLatest
2e2
8b3
Bra
nch
d19
e69
Rebasing
a32
8b3
Bra
nch
d19
e69
Rebase
Master/Trunk/MainLatest
2e2
Rebasing
a32
8b3
Bra
nch
d19'
e69'
Rebase
Master/Trunk/MainLatest
2e2
Rebasing
a32
8b3
Bra
nch
d19'
ge
r
Me
Master/Trunk/MainLatest
2e2
e69'
Rebasing
Rebasing
Rebasing
Interactive rebasing
Rebasing
Rebasing
Master/Trunk/MainLatest
a32
2e2
8b3
d19
e69
Rebasing
Master/Trunk/MainLatest
a32
2e2
d19
e69
Rebasing
Master/Trunk/MainLatest
a32
2e2
d19
e69
Rebasing
Master/Trunk/MainLatest
a32
2e2
d19
e69
Rebasing
Master/Trunk/MainLatest
a32
d19
2e2
e69
Rebasing
Master/Trunk/MainLatest
a32
d19
2e2
e69
Rebasing
Master/Trunk/MainLatest
a32
d19
e69 2e2
Rebasing
Rebasing
Workows
Usage Models
Centralized
Central
Repo
Usage Models
Dictatorship
Blessed
Repo
Usage Models
Certied
Repo
Continuous
Integration
Server
ntegration Managed
Development Repo
Usage Models
Private
Customized
Public
GitHub
Usage Models
Certied
Repo
Mirror
Development Repo
Mirrored
Mirror
Usage Models
Undo
Clean
Clean
git clean -n
Clean
Clean
# Remove files
git clean -f
Clean
Clean
Undo
Clean
Clean
Clean
Clean
Undo
Undo
Revert
Revert
Revert
Revert
Revert
a32
2e2
8b3
8b3 '
d19'
Revert
a32
2e2
8b3
Re
ve
r
d19'
8b3 '
Revert
Revert
Revert
Revert
Revert
order
Revert
Undo
Amend
amend
Amend
Amend
Amend
Amend
Amend a missing le
Amend
Git-SVN
Cloning
git-svn
git-svn
git-svn
svn2git
https://github.com/nirvdrum/svn2git
Converts tags to Git tags
git-svn
Git-SVN
Updating
git
svn rebase
git-svn
git
svn dcommit
git-svn
Git-SVN
SVN Externals
SVN Externals
No direct support
Represented as separate repos
Git points at a stable snapshot
SVN Externals follow changes on a branch
git-svn
git-svn
https://github.com/andrep/git-svn-clone-externals
git-svn
Ofcial
Git Foundations
An exploration of the Git toolbox
@matthewmccull
matthew@github.com
github.com/training
AmbientIdeasPhotography.com
Hand Tools
Clock: http://www.ickr.com/photos/7729940@N06/4019157830
Credits