Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit …...

111
The Git Parable Johan Herland <[email protected]>

Transcript of Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit …...

Page 1: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

Johan Herland

<[email protected]>

Page 2: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Shamelessly stolen from Tom Preston-Wernerhttp://tom.preston-werner.com/2009/05/19/the-git-parable.html

● I'm lazy...● Also: Best introduction to Git I've found so far

Page 3: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

Page 4: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

git initgit add …git commit …git branch …git checkout …git tag …git diff …git log …git remote …git fetch …git pull …git push …...

Page 5: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

git initgit add …git commit …git branch …git checkout …git tag …git diff …git log …git remote …git fetch …git pull …git push …...

TADAA!!!

Page 6: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

git initgit add …git commit …git branch …git checkout …git tag …git diff …git log …git remote …git fetch …git pull …git push …...

TADAA!!!

Page 7: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

Let's tell a parable

Page 8: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

Page 9: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Git Parable

● Git - simple & powerful

Eureka!

Page 10: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Parable

● A simple computer

– A text editor– A few filesystem commands

Page 11: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Parable

● Write a large software program

Page 12: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The Parable

● Write a large software program● Invent some method to keep track of versions

– retrieve code that you changed/deleted

Responsible!

Page 13: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

● Alfred, the photographer

Alfred

Page 14: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

● Alfred, the photographer

Alfred

Page 15: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

● Alfred, the photographer● Hazel and her daughter

Hazel

daughter

Page 16: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

● Alfred, the photographer● Hazel and her daughter

– Remember what thedaughter was like ateach different stage

Page 17: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

● Alfred, the photographer● Hazel and her daughter

– Remember what thedaughter was like ateach different stage

Eureka!

Page 18: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

working

Page 19: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

working working.copy

Page 20: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

working snapshot-0working.copy

Page 21: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

working snapshot-0 snapshot-1

Page 22: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Snapshots

working snapshot-0 snapshot-1

message message

2009-05-20 12:34:56

Initial version

2009-05-21 23:45:01

Introduced a new foo,and reset the bar toxyzzy.

Page 23: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

Page 24: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

w00t! cool!

nice!

Page 25: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

. . .snapshot-109

Page 26: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

Does not work!

Boo!

. . .snapshot-109

Page 27: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

. . .snapshot-109

Page 28: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

working snapshot-0 snapshot-1

. . .

snapshot-99

. . .snapshot-109

?snapshot-110

?

Page 29: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

Page 30: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

Eureka!

Page 31: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

Page 32: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branches

snapshot-0snapshot-1

message

2009-05-21 23:45:01parent: snapshot-0

Introduced a new foo,and reset the bar toxyzzy.

Page 33: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branch Names

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Page 34: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Branch Names

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Page 35: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

snapshot-X

Branch Names

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

snapshot-X

snapshot-X

snapshot-X

Page 36: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

snapshot-X

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

snapshot-X

snapshot-X

snapshot-X

Branch Names

?

Page 37: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Branch Names

This will be the“Version 1.0 Maintenance” Branch

This is the“master” branch

Page 38: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Branch Names

This is the“Version 1.0 Maintenance” Branch.

It contains:snapshot-110

(and its ancestors)

This is the“master” branch.

It contains:snapshot-109

(and its ancestors)

Page 39: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Branch Names

branches

master: snapshot-109v1.0-maint: snapshot-110

Page 40: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Branch Names

branches

master: snapshot-109v1.0-maint: snapshot-111

snapshot-111

Page 41: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

snapshot-0

snapshot-1

snapshot-99

snapshot-109

snapshot-110

Tags

branches

master: snapshot-109v1.0-maint: snapshot-111

snapshot-111

tags

v1.0: snapshot-99v1.0.1: snapshot-110

Page 42: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags Sigh...

Page 43: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags Hi Zoe!Zoe

Page 44: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

Page 45: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

Bye!

Page 46: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

snapshot-114

snapshot-115

snapshot-114

snapshot-115

Page 47: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Distributed

2009-05-21 23:45:01parent: snapshot-113author: Zoe <[email protected]>

Introduced a new foo,and reset the bar toxyzzy.

snapshot-114

message

snapshot-114

message

2009-05-22 12:12:12parent: snapshot-113author: Me <[email protected]>

Blarfle, a cool newfeature; extends theexisting blorg.

Page 48: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Distributed

message

SHA1

8ba3441b6b89cad23387ee875f2ae55069291f4b

2009-05-22 12:12:12parent: snapshot-113author: Me <[email protected]>

Blarfle, a cool newfeature; extends theexisting blorg.

2009-05-21 23:45:01parent: snapshot-113author: Zoe <[email protected]>

Introduced a new foo,and reset the bar toxyzzy.

message

SHA1

db9ecb5b5a6294a8733503ab57577db96ff2249e

Page 49: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

8ba3441…

083dbcf…

db9ecb5…

575db4b…

Page 50: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

8ba3441…

083dbcf…

db9ecb5…

575db4b…

?

Page 51: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

8ba3441…

083dbcf…

db9ecb5…

575db4b…

db9ecb5…

575db4b…

Page 52: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Distributed

branches

tags

branches

tags

working

8ba3441…

083dbcf…

db9ecb5…

575db4b…

db9ecb5…

575db4b…

Page 53: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Offline

branches

tags

branches

tags

working

w00t!

Page 54: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

working

Offline

branches

tags

branches

tags

working

Page 55: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

branches

tags

workingworking

branches

tags

(simpler drawings)

Page 56: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

(simpler drawings)

master

v1.0.1

v1.0

v1.0-maint

v1.0

v1.0.1

v1.0-maint

master

math math

Page 57: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

(simpler drawings)

master

v1.0

v1.0-maint

v1.0.1

master

v1.0

v1.0-maint

v1.0.1

math math

Page 58: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Merges

master

v1.0

v1.0-maint

v1.0.1

master

v1.0

v1.0-maint

v1.0.1

math

math

Page 59: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Merges

master

v1.0

v1.0-maint

v1.0.1

master

v1.0

v1.0-maint

v1.0.1

math

math

?

Page 60: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Merges

master

v1.0

v1.0-maint

v1.0.1

master

v1.0

v1.0-maint

v1.0.1

math

math

Page 61: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Merges

master

v1.0

v1.0-maint

v1.0.1

master

v1.0

v1.0-maint

v1.0.1

math math

Page 62: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

Hic!

Page 63: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

Page 64: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

drunk^

Page 65: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

drunk^

drunk^^

Page 66: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

Page 67: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

Page 68: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

drunk^^^

Page 69: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

Page 70: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunkdrunk

Page 71: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Rewriting History

master

v1.0

v1.0-maint

v1.0.1

math

drunk

Page 72: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

Oops...

Page 73: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

Page 74: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

Page 75: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

Page 76: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

master

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

Page 77: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Staging Area

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

README

master

Page 78: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Diffs

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

What are the changes?- working vs. staging- working vs. snapshot X- staging vs. snapshot X- snapshot X vs. snapshot Y

master

Page 79: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Diffs

v1.0

v1.0-maint

v1.0.1

math

drunk

working staging

master

Diff algorithm

--- staging+++ working

foo-baz+bazzle xyzzy

Page 80: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Diffs

v1.0

v1.0-maint

v1.0.1

math

drunk

working staging

master

--- 90b69eb...+++ staging

foo-bar+baz xyzzy

Page 81: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Diffs

v1.0

v1.0-maint

v1.0.1

math

drunk

working staging

master

--- 1573d45...+++ 90b69eb...

foo bar+xyzzy

Page 82: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Diffs

v1.0

v1.0-maint

v1.0.1

math

drunk

working staging

master

--- 90b69eb...+++ 5fa5d28...

foo bar-xyzzy+lorem ipsum dolor+sit amet, ...

Page 83: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

v1.0

v1.0-maint

v1.0.1

math

working

staging

master

Page 84: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

Eureka!

SHA1

2804133755c3ed396d162028c7b30a1cbcfecded

objects

Page 85: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objectsc3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3 file2 file1

Temp file

file4

Page 86: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

SHA1

objects

Temp file

a8458149fd2f6d1573d45707607d0befb8decb30

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3 file2 file1

file4

Page 87: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

blob a8458149fd2f6d1573d45707607d0befb8decb30 file1

Temp file

a8458149fd2f6d1573d45707607d0befb8decb30

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3 file2 file1

file4

Page 88: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3 file2 file1

file4

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

blob a8458149fd2f6d1573d45707607d0befb8decb30 file1

Temp file

a8458149fd2f6d1573d45707607d0befb8decb30

Page 89: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3 file2

file4

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

blob a8458149fd2f6d1573d45707607d0befb8decb30 file1blob ef1f8810341ab1e9948d5e49d2a03e1ce586b1a0 file2

ef1f8810341ab1e9948d5e49d2a03e1ce586b1a0

SHA1

Page 90: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1

file3

file4

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

blob a8458149fd2f6d1573d45707607d0befb8decb30 file1blob ef1f8810341ab1e9948d5e49d2a03e1ce586b1a0 file2blob 376256ffd8737954c129dfc2f6f7cffc559b78b7 file3

376256ffd8737954c129dfc2f6f7cffc559b78b7

SHA1

Page 91: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

blob a8458149fd2f6d1573d45707607d0befb8decb30 file1blob ef1f8810341ab1e9948d5e49d2a03e1ce586b1a0 file2blob 376256ffd8737954c129dfc2f6f7cffc559b78b7 file3

8aa73a2b1cf458c7c88dc16202ae794f5c99ef10

SHA1

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1file4

Page 92: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

tree 8aa73a2b1cf458c7c88dc16202ae794f5c99ef10 subsubdir1

8aa73a2b1cf458c7c88dc16202ae794f5c99ef10

New temp file

c3c769c(aka snapshot-0)

subdir1 subdir2

subsubdir1file4

Page 93: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

c3c769c(aka snapshot-0)

subdir1 subdir2

file4

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

tree 8aa73a2b1cf458c7c88dc16202ae794f5c99ef10 subsubdir1blob be17eaddd5e696239e8a5f6e6e3dbce524707983 file4

be17eaddd5e696239e8a5f6e6e3dbce524707983

New temp file

SHA1

Page 94: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

67a3c2a9119a3c3c769c0b1e8735fa5d28d94a12

SHA1

tree 8aa73a2b1cf458c7c88dc16202ae794f5c99ef10 subsubdir1blob be17eaddd5e696239e8a5f6e6e3dbce524707983 file4

c3c769c(aka snapshot-0)

subdir1 subdir2

Page 95: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

c3c769c(aka snapshot-0)

subdir1 subdir2

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

8ff0b253a4f3744576427c7dd575db4bfdb8259d

SHA1

tree 2804133755c3ed396d162028c7b30a1cbcfecded subdir1tree 67a3c2a9119a3c3c769c0b1e8735fa5d28d94a12 subdir2

New temp file

Page 96: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objectsc3c769c(aka snapshot-0)

8ff0b253a4f3744576427c7dd575db4bfdb8259d

Page 97: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objectsc3c769c(aka snapshot-0)

8ff0b253a4f3744576427c7dd575db4bfdb8259dmessage

tree: 8ff0b253a4f3744576427c7dd575db4bfdb8259ddate: 2009-05-22 12:12:12author: Me <[email protected]>

Initial version

Page 98: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objectsc3c769c(aka snapshot-0)

5a2fa987819083dbcf44d36697b7ecbe3bfc9a3f

tree: 8ff0b253a4f3744576427c7dd575db4bfdb8259ddate: 2009-05-22 12:12:12author: Me <[email protected]>

Initial version

SHA1

Page 99: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

Page 100: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

Page 101: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Eliminating Duplication

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

Page 102: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Compressing Blobs

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

ZLIB

Page 103: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

The True Git

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

● TADAA!● This is pretty much Git● Nicer command line tools

for all these operations● Many, many other tools

Page 104: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Commands: Getting Started

● First, tell Git who you are:– git config --global user.name “My Name”

– git config --global user.email “[email protected]

● Get help:

– git <command> -h– git help <command>

● Start a new Git repository:

– git init

Page 105: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Commands: Making snapshots

working staging

staging snapshot

git commit -a}

snapshot snapshot

...

● git add

● git commit

● git log

● git statusworking staging

?/

gitk

Page 106: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Commands: Diffing

working staging

staging snapshot

snapshot

snapshot snapshot

vs.

● git diff

● git diff --staged

● git diff HEAD

● git diff <from> <to>

vs.

vs.

working

vs.

Page 107: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Commands: Branches & Tags

● git branch

● git branch <branch>

● git checkout <branch>

● git tag -l

● git tag <tag>

git checkout -b ...}

Page 108: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Commands: Fetching & Merging

● git remote add <name> <URL>

● git fetch <name>

● git merge <name>/<branch>

git pull}

Page 109: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Conclusion

v1.0

v1.0-maint

v1.0.1

math

drunk

working

staging

master

objects

● Keep this parable in mind● Git is simple and powerful

● One more thing:

git reflog

Page 110: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Where to go next?

● Git homepage: http://git-scm.com● Pro Git: http://git-scm.com/book● Git Reference: http://gitref.org● GitHub: http://github.com● Gitorious: http://gitorious.org

Page 111: Johan Herland €¦ · The Git Parable Git - simple & powerful git init git add … git commit … git branch … git checkout … git tag … git diff …

Questions?

● Thanks for your attention!

● These slides are available at:https://github.com/jherland/git_parable

● Reach me at <[email protected]>