Slide 1

Slide 1 text

Kerry  Buckley  –  9  March  2015

Slide 2

Slide 2 text

Topics

Slide 3

Slide 3 text

Background Topics

Slide 4

Slide 4 text

Background The basics Topics

Slide 5

Slide 5 text

Background The basics Precision staging Topics

Slide 6

Slide 6 text

Background The basics Precision staging Branches Topics

Slide 7

Slide 7 text

Background The basics Precision staging Branches Tags Topics

Slide 8

Slide 8 text

Background The basics Precision staging Branches Tags Internals Topics

Slide 9

Slide 9 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Topics

Slide 10

Slide 10 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Topics

Slide 11

Slide 11 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Topics

Slide 12

Slide 12 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Team workflows Topics

Slide 13

Slide 13 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Team workflows Hooks Topics

Slide 14

Slide 14 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Team workflows Hooks Rewriting history Topics

Slide 15

Slide 15 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Team workflows Hooks Rewriting history Working with svn Topics

Slide 16

Slide 16 text

Background The basics Precision staging Branches Tags Internals Merge & rebase Distributed git Patches & email Team workflows Hooks Rewriting history Working with svn Fixing mistakes Topics

Slide 17

Slide 17 text

Part I: Background In which we look at some fundamental concepts, and learn to ignore most of git’s multitude of commands

Slide 18

Slide 18 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File

Slide 19

Slide 19 text

Bob’s  computer Server Alice’s  computer Version  DB Version  3 Version  2 Version  1 File File

Slide 20

Slide 20 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File

Slide 21

Slide 21 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File

Slide 22

Slide 22 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File Bob’s  computer Version  DB Version  3 Version  2 Version  1 File Server Version  DB Version  3 Version  2 Version  1

Slide 23

Slide 23 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File Bob’s  computer Version  DB Version  3 Version  2 Version  1 File Server Version  DB Version  3 Version  2 Version  1

Slide 24

Slide 24 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File Index   (staging  area)

Slide 25

Slide 25 text

add add‑‑interactive am annotate apply archimport archive bisect bisect‑‑helper blame branch bundle cat‑file check‑attr check‑ignore check‑mailmap check‑ref‑format checkout checkout‑index cherry cherry‑pick citool clean clone column commit commit‑tree config count‑objects credential credential‑cache credential‑cache‑‑daemon credential‑store cvsexportcommit cvsimport cvsserver daemon describe diff diff‑files diff‑index diff‑tree difftool difftool‑‑helper fast‑export fast‑import fetch fetch‑pack filter‑branch fmt‑merge‑msg for‑each‑ref format‑patch fsck fsck‑objects gc get‑tar‑commit‑id grep gui gui‑‑askpass hash‑object help http‑backend http‑fetch http‑push index‑pack init init‑db instaweb interpret‑trailers log ls‑files ls‑remote ls‑tree mailinfo mailsplit merge merge‑base merge‑file merge‑index merge‑octopus merge‑one‑file merge‑ours merge‑recursive merge‑resolve merge‑subtree merge‑tree mergetool mktag mktree mv name‑rev notes p4 pack‑objects pack‑redundant pack‑refs patch‑id prune prune‑packed pull push quiltimport read‑tree rebase receive‑pack reflog relink remote remote‑ext remote‑fd remote‑ftp remote‑ftps remote‑http remote‑https remote‑testsvn repack replace request‑pull rerere reset rev‑list rev‑parse revert rm send‑email send‑pack sh‑i18n‑‑envsubst shell shortlog show show‑branch show‑index show‑ref stage stash status stripspace submodule svn symbolic‑ref tag unpack‑file unpack‑objects update‑index update‑ref update‑server‑info upload‑archive upload‑pack var verify‑commit verify‑pack verify‑tag web‑‑browse whatchanged write‑tree h"ps:/ /www.flickr.com/photos/abirkill/3494123087

Slide 26

Slide 26 text

h"ps:/ /www.flickr.com/photos/loop_oh/6277684962 h"ps:/ /www.flickr.com/photos/abirkill/3494123087

Slide 27

Slide 27 text

add add‑‑interactive am annotate apply archimport archive bisect bisect‑‑helper blame branch bundle cat‑file check‑attr check‑ignore check‑mailmap check‑ref‑format checkout checkout‑index cherry cherry‑pick citool clean clone column commit commit‑tree config count‑objects credential credential‑cache credential‑cache‑‑daemon credential‑store cvsexportcommit cvsimport cvsserver daemon describe diff diff‑files diff‑index diff‑tree difftool difftool‑‑helper fast‑export fast‑import fetch fetch‑pack filter‑branch fmt‑merge‑msg for‑each‑ref format‑patch fsck fsck‑objects gc get‑tar‑commit‑id grep gui gui‑‑askpass hash‑object help http‑backend http‑fetch http‑push index‑pack init init‑db instaweb interpret‑trailers log ls‑files ls‑remote ls‑tree mailinfo mailsplit merge merge‑base merge‑file merge‑index merge‑octopus merge‑one‑file merge‑ours merge‑recursive merge‑resolve merge‑subtree merge‑tree mergetool mktag mktree mv name‑rev notes p4 pack‑objects pack‑redundant pack‑refs patch‑id prune prune‑packed pull push quiltimport read‑tree rebase receive‑pack reflog relink remote remote‑ext remote‑fd remote‑ftp remote‑ftps remote‑http remote‑https remote‑testsvn repack replace request‑pull rerere reset rev‑list rev‑parse revert rm send‑email send‑pack sh‑i18n‑‑envsubst shell shortlog show show‑branch show‑index show‑ref stage stash status stripspace submodule svn symbolic‑ref tag unpack‑file unpack‑objects update‑index update‑ref update‑server‑info upload‑archive upload‑pack var verify‑commit verify‑pack verify‑tag web‑‑browse whatchanged write‑tree

Slide 28

Slide 28 text

add add‑‑interactive am annotate apply archimport archive bisect bisect‑‑helper blame branch bundle cat‑file check‑attr check‑ignore check‑mailmap check‑ref‑format checkout checkout‑index cherry cherry‑pick citool clean clone column commit commit‑tree config count‑objects credential credential‑cache credential‑cache‑‑daemon credential‑store cvsexportcommit cvsimport cvsserver daemon describe diff diff‑files diff‑index diff‑tree difftool difftool‑‑helper fast‑export fast‑import fetch fetch‑pack filter‑branch fmt‑merge‑msg for‑each‑ref format‑patch fsck fsck‑objects gc get‑tar‑commit‑id grep gui gui‑‑askpass hash‑object help http‑backend http‑fetch http‑push index‑pack init init‑db instaweb interpret‑trailers log ls‑files ls‑remote ls‑tree mailinfo mailsplit merge merge‑base merge‑file merge‑index merge‑octopus merge‑one‑file merge‑ours merge‑recursive merge‑resolve merge‑subtree merge‑tree mergetool mktag mktree mv name‑rev notes p4 pack‑objects pack‑redundant pack‑refs patch‑id prune prune‑packed pull push quiltimport read‑tree rebase receive‑pack reflog relink remote remote‑ext remote‑fd remote‑ftp remote‑ftps remote‑http remote‑https remote‑testsvn repack replace request‑pull rerere reset rev‑list rev‑parse revert rm send‑email send‑pack sh‑i18n‑‑envsubst shell shortlog show show‑branch show‑index show‑ref stage stash status stripspace submodule svn symbolic‑ref tag unpack‑file unpack‑objects update‑index update‑ref update‑server‑info upload‑archive upload‑pack var verify‑commit verify‑pack verify‑tag web‑‑browse whatchanged write‑tree

Slide 29

Slide 29 text

Part II: The Basics In which we create a repository, add a few files to it, and track some changes

Slide 30

Slide 30 text

Create a new repository

Slide 31

Slide 31 text

Initialized empty Git repository in /Users/kerry/masterclass/.git/ Create a new repository $ git init

Slide 32

Slide 32 text

Add a new file

Slide 33

Slide 33 text

On branch master Initial commit Untracked files: (use "git add ..." to include in what will be committed) foo.txt nothing added to commit but untracked files present (use "git add" to track) Add a new file $ git status

Slide 34

Slide 34 text

Add a new file

Slide 35

Slide 35 text

Add a new file $ git add foo.txt

Slide 36

Slide 36 text

On branch master Initial commit Changes to be committed: (use "git rm --cached ..." to unstage) new file: foo.txt Add a new file $ git add foo.txt $ git status

Slide 37

Slide 37 text

Add a new file

Slide 38

Slide 38 text

[master (root-commit) 80ab5d4] Add a file with some placeholder text 1 file changed, 6 insertions(+) create mode 100644 foo.txt Add a new file $ git commit -m"Add a file with some placeholder text"

Slide 39

Slide 39 text

Commit a change

Slide 40

Slide 40 text

On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: foo.txt no changes added to commit (use "git add" and/or "git commit -a") Commit a change $ git status

Slide 41

Slide 41 text

Commit a change

Slide 42

Slide 42 text

diff --git a/foo.txt b/foo.txt index e1bc2ab..d66717b 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,6 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis -nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Commit a change $ git diff

Slide 43

Slide 43 text

Commit a change

Slide 44

Slide 44 text

Commit a change $ git add foo.txt

Slide 45

Slide 45 text

On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) modified: foo.txt Commit a change $ git add foo.txt $ git status

Slide 46

Slide 46 text

Commit a change

Slide 47

Slide 47 text

Commit a change $ git commit -m"Insert some magic into the text"

Slide 48

Slide 48 text

[master 9e2546a] Insert some magic into the text 1 file changed, 1 insertion(+), 1 deletion(-) Commit a change $ git commit -m"Insert some magic into the text"

Slide 49

Slide 49 text

Alice’s  computer Version  DB Version  3 Version  2 Version  1 File Index   (staging  area) add rm mv commit

Slide 50

Slide 50 text

Viewing history

Slide 51

Slide 51 text

commit 9e2546aef0232daf56635b6319bcf69f788bd5ba Author: Kerry Buckley Date: 42 seconds ago Insert some magic into the text commit 80ab5d44f47c0c2dbbf8ade76d4f85889295d8a4 Author: Kerry Buckley Date: 10 minutes ago Add a file with some placeholder text Viewing history $ git log

Slide 52

Slide 52 text

Viewing a commit

Slide 53

Slide 53 text

commit 9e2546aef0232daf56635b6319bcf69f788bd5ba Author: Kerry Buckley Date: 2 hours ago Insert some magic into the text diff --git a/foo.txt b/foo.txt index e1bc2ab..d66717b 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,6 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis -nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Viewing a commit $ git show 9e2546aef0232daf56635b6319bcf69f788bd5ba

Slide 54

Slide 54 text

Viewing a commit

Slide 55

Slide 55 text

commit 9e2546aef0232daf56635b6319bcf69f788bd5ba Author: Kerry Buckley Date: 2 hours ago Insert some magic into the text foo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Viewing a commit $ git show --stat 9e2546aef0232daf56635b6319bcf69f788bd5ba

Slide 56

Slide 56 text

Viewing a commit

Slide 57

Slide 57 text

commit 9e2546aef0232daf56635b6319bcf69f788bd5ba Author: Kerry Buckley Date: 2 hours ago Insert some magic into the text 1 file changed, 1 insertion(+), 1 deletion(-) Viewing a commit $ git show --shortstat 9e2546aef0232daf56635b6319bcf69f788bd5ba

Slide 58

Slide 58 text

Diff (working dir ↔ staged)

Slide 59

Slide 59 text

diff --git a/foo.txt b/foo.txt index e1bc2ab..d66717b 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,6 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis -nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Diff (working dir ↔ staged) $ git diff

Slide 60

Slide 60 text

Diff (working dir ↔ staged)

Slide 61

Slide 61 text

foo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Diff (working dir ↔ staged) $ git diff —stat

Slide 62

Slide 62 text

Diff (arbitrary references)

Slide 63

Slide 63 text

diff --git a/foo.txt b/foo.txt index e1bc2ab..d66717b 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,6 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis -nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Diff (arbitrary references) $ git diff 80ab5d4 9e2546a

Slide 64

Slide 64 text

The pickaxe

Slide 65

Slide 65 text

The pickaxe $ git log -S expelliarmus

Slide 66

Slide 66 text

commit 9e2546aef0232daf56635b6319bcf69f788bd5ba Author: Kerry Buckley Date: 5 minutes ago Insert some magic into the text The pickaxe $ git log -S expelliarmus

Slide 67

Slide 67 text

Who did what?

Slide 68

Slide 68 text

Who did what? $ git blame foo.txt

Slide 69

Slide 69 text

^80ab5d4 (Kerry Buckley 2015-03-08 09:45:43 +0000 1) Lorem ipsum dolor sit amet ^80ab5d4 (Kerry Buckley 2015-03-08 09:45:43 +0000 2) incididunt ut labore et do 9e2546ae (Kerry Buckley 2015-03-08 09:54:31 +0000 3) expelliarmus wingardium le ^80ab5d4 (Kerry Buckley 2015-03-08 09:45:43 +0000 4) Duis aute irure dolor in r ^80ab5d4 (Kerry Buckley 2015-03-08 09:45:43 +0000 5) fugiat nulla pariatur. Ex ^80ab5d4 (Kerry Buckley 2015-03-08 09:45:43 +0000 6) culpa qui officia deserunt Who did what? $ git blame foo.txt

Slide 70

Slide 70 text

Add note about good messages Add a note explaining how people should format commit messages. Bad commit messages can cause a number of problems: * Truncation of long lines when using git log, and other commands that understand commit commit subject/body separation * Badly-formatted emails from git format-patch * Rejection of pull requests by pedantic maintainers Good commit messages

Slide 71

Slide 71 text

Add note about good messages Add a note explaining how people should format commit messages. Bad commit messages can cause a number of problems: * Truncation of long lines when using git log, and other commands that understand commit commit subject/body separation * Badly-formatted emails from git format-patch * Rejection of pull requests by pedantic maintainers Good commit messages Summary  (up  to  ~50  chars)

Slide 72

Slide 72 text

Add note about good messages Add a note explaining how people should format commit messages. Bad commit messages can cause a number of problems: * Truncation of long lines when using git log, and other commands that understand commit commit subject/body separation * Badly-formatted emails from git format-patch * Rejection of pull requests by pedantic maintainers Good commit messages Impera5ve  mode  (‘add’,  not  ‘added’)

Slide 73

Slide 73 text

Add note about good messages Add a note explaining how people should format commit messages. Bad commit messages can cause a number of problems: * Truncation of long lines when using git log, and other commands that understand commit commit subject/body separation * Badly-formatted emails from git format-patch * Rejection of pull requests by pedantic maintainers Good commit messages Blank  line

Slide 74

Slide 74 text

Add note about good messages Add a note explaining how people should format commit messages. Bad commit messages can cause a number of problems: * Truncation of long lines when using git log, and other commands that understand commit commit subject/body separation * Badly-formatted emails from git format-patch * Rejection of pull requests by pedantic maintainers Good commit messages More  info,  if  necessary  –  wrap  at  72  chars

Slide 75

Slide 75 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 76

Slide 76 text

Part III: Precision staging In which ‘git add’ turns out to be not as clumsy or random as a blaster. An elegant weapon, for a more civilized age.

Slide 77

Slide 77 text

Adding in patch mode

Slide 78

Slide 78 text

diff --git a/foo.txt b/foo.txt index d66717b..de5974e 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,11 @@ +This is a file full of nonsense. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Adding in patch mode $ git diff

Slide 79

Slide 79 text

Adding in patch mode

Slide 80

Slide 80 text

diff --git a/foo.txt b/foo.txt index d66717b..de5974e 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,11 @@ +This is a file full of nonsense. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Stage this hunk [y,n,q,a,d,/,s,e,?]? Adding in patch mode $ git add -p foo.txt

Slide 81

Slide 81 text

Adding in patch mode

Slide 82

Slide 82 text

Split into 2 hunks. @@ -1,6 +1,8 @@ +This is a file full of nonsense. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? Adding in patch mode Stage this hunk [y,n,q,a,d,/,s,e,?]? s

Slide 83

Slide 83 text

Adding in patch mode

Slide 84

Slide 84 text

@@ -1,6 +3,9 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? Adding in patch mode Stage this hunk [y,n,q,a,d,/,s,e,?]? y

Slide 85

Slide 85 text

Adding in patch mode

Slide 86

Slide 86 text

Adding in patch mode Stage this hunk [y,n,q,a,d,/,s,e,?]? n

Slide 87

Slide 87 text

On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) modified: foo.txt Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: foo.txt Adding in patch mode Stage this hunk [y,n,q,a,d,/,s,e,?]? n $ git status

Slide 88

Slide 88 text

Adding in interactive mode

Slide 89

Slide 89 text

On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: foo.txt Untracked files: (use "git add ..." to include in what will be committed) bar.txt no changes added to commit (use "git add" and/or "git commit -a") Adding in interactive mode $ git status

Slide 90

Slide 90 text

Adding in interactive mode

Slide 91

Slide 91 text

staged unstaged path 1: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> Adding in interactive mode $ git add -i

Slide 92

Slide 92 text

Adding in interactive mode $ git add -i staged unstaged path 1: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> a 1: bar.txt Add untracked>>

Slide 93

Slide 93 text

Adding in interactive mode $ git add -i staged unstaged path 1: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> a 1: bar.txt Add untracked>> 1 * 1: bar.txt Add untracked>>

Slide 94

Slide 94 text

Adding in interactive mode $ git add -i staged unstaged path 1: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> a 1: bar.txt Add untracked>> 1 * 1: bar.txt Add untracked>> added one path *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now>

Slide 95

Slide 95 text

Adding in interactive mode

Slide 96

Slide 96 text

staged unstaged path 1: +0/-0 nothing bar.txt 2: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> Adding in interactive mode What now> s

Slide 97

Slide 97 text

Adding in interactive mode What now> s staged unstaged path 1: +0/-0 nothing bar.txt 2: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> p staged unstaged path 1: unchanged +5/-0 foo.txt Patch update>>

Slide 98

Slide 98 text

Adding in interactive mode What now> s staged unstaged path 1: +0/-0 nothing bar.txt 2: unchanged +5/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> p staged unstaged path 1: unchanged +5/-0 foo.txt Patch update>> 1 staged unstaged path * 1: unchanged +5/-0 foo.txt Patch update>>

Slide 99

Slide 99 text

Adding in interactive mode

Slide 100

Slide 100 text

diff --git a/foo.txt b/foo.txt index d66717b..de5974e 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,11 @@ +This is a file full of nonsense. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Stage this hunk [y,n,q,a,d,/,s,e,?]? Adding in interactive mode Patch update>>

Slide 101

Slide 101 text

Adding in interactive mode

Slide 102

Slide 102 text

Split into 2 hunks. @@ -1,6 +1,8 @@ +This is a file full of nonsense. + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Stage this hunk [y,n,q,a,d,/,s,e,?]? Adding in interactive mode Stage this hunk [y,n,q,a,d,/,s,e,?]? s

Slide 103

Slide 103 text

Adding in interactive mode

Slide 104

Slide 104 text

@@ -1,6 +3,9 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Stage this hunk [y,n,q,a,d,/,s,e,?]? Adding in interactive mode Stage this hunk [y,n,q,a,d,/,s,e,?]? y

Slide 105

Slide 105 text

Adding in interactive mode Stage this hunk [y,n,q,a,d,/,s,e,?]? y @@ -1,6 +3,9 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum + +Pop-up Austin mustache Tumblr Kickstarter next level scenester, typewriter +pour-over. Bespoke gentrify vegan, authentic beard fixie locavore tofu actually. Stage this hunk [y,n,q,a,d,/,s,e,?]? n *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now>

Slide 106

Slide 106 text

Adding in interactive mode

Slide 107

Slide 107 text

staged unstaged path 1: +0/-0 nothing bar.txt 2: +2/-0 +3/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> Adding in interactive mode What now> s

Slide 108

Slide 108 text

Adding in interactive mode What now> s staged unstaged path 1: +0/-0 nothing bar.txt 2: +2/-0 +3/-0 foo.txt *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now> q Bye.

Slide 109

Slide 109 text

Adding in interactive mode

Slide 110

Slide 110 text

On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) new file: bar.txt modified: foo.txt Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: foo.txt Adding in interactive mode $ git status

Slide 111

Slide 111 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 112

Slide 112 text

Part IV: Branches In which things start to get a little more complicated

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

Create a branch

Slide 115

Slide 115 text

Switched to a new branch 'my-new-branch' Create a branch $ git checkout -b my-new-branch

Slide 116

Slide 116 text

Branch from a specific point

Slide 117

Slide 117 text

Switched to a new branch 'my-new-branch' Branch from a specific point $ git checkout -b my-new-branch 80ab5d

Slide 118

Slide 118 text

Switched to a new branch 'my-new-branch' Branch from a specific point $ git checkout -b my-new-branch 80ab5d Anything  ‘commit-­‐ish’

Slide 119

Slide 119 text

Referring to commits

Slide 120

Slide 120 text

Referring to commits Full or partial SHA

Slide 121

Slide 121 text

Referring to commits Full or partial SHA 9e2546aef0232daf56635b6319bcf69f788bd5ba

Slide 122

Slide 122 text

Referring to commits Full or partial SHA 9e2546aef0232daf56635b6319bcf69f788bd5ba 9e2546a

Slide 123

Slide 123 text

Referring to commits Full or partial SHA 9e2546aef0232daf56635b6319bcf69f788bd5ba 9e2546a 9e25

Slide 124

Slide 124 text

Referring to commits

Slide 125

Slide 125 text

Referring to commits Branch, tag, or current head

Slide 126

Slide 126 text

Referring to commits Branch, tag, or current head master

Slide 127

Slide 127 text

Referring to commits Branch, tag, or current head master my-branch

Slide 128

Slide 128 text

Referring to commits Branch, tag, or current head master my-branch release-1

Slide 129

Slide 129 text

Referring to commits Branch, tag, or current head master my-branch release-1 HEAD

Slide 130

Slide 130 text

Referring to commits

Slide 131

Slide 131 text

Referring to commits Ancestors of other commits

Slide 132

Slide 132 text

Referring to commits Ancestors of other commits HEAD~

Slide 133

Slide 133 text

Referring to commits Ancestors of other commits HEAD~ master~~~

Slide 134

Slide 134 text

Referring to commits Ancestors of other commits HEAD~ master~~~ master~3

Slide 135

Slide 135 text

Referring to commits Ancestors of other commits HEAD~ master~~~ master~3 9e2546a^

Slide 136

Slide 136 text

Referring to commits Ancestors of other commits HEAD~ master~~~ master~3 9e2546a^ 9e2546a^2

Slide 137

Slide 137 text

Referring to commits Ancestors of other commits HEAD~ master~~~ master~3 9e2546a^ 9e2546a^2 9e2546a^2~3

Slide 138

Slide 138 text

Delete a branch

Slide 139

Slide 139 text

error: The branch 'my-new-branch' is not fully merged. If you are sure you want to delete it, run 'git branch -D my-new-branch'. Delete a branch $ git branch -d my-new-branch

Slide 140

Slide 140 text

error: The branch 'my-new-branch' is not fully merged. If you are sure you want to delete it, run 'git branch -D my-new-branch'. Delete a branch $ git branch -d my-new-branch Deleted branch my-new-branch (was 69a5438). $ git branch -D my-new-branch

Slide 141

Slide 141 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 142

Slide 142 text

Part V: Tags In which we wander around our repository, pointing at things

Slide 143

Slide 143 text

Create, move and delete a tag

Slide 144

Slide 144 text

Create, move and delete a tag $ git tag my-tag

Slide 145

Slide 145 text

Create, move and delete a tag $ git tag my-tag fatal: tag 'my-tag' already exists $ git tag my-tag 80ab5d4

Slide 146

Slide 146 text

Create, move and delete a tag $ git tag my-tag fatal: tag 'my-tag' already exists $ git tag my-tag 80ab5d4 Updated tag 'my-tag' (was 9e2546a) $ git tag -f my-tag 80ab5d4

Slide 147

Slide 147 text

Create, move and delete a tag $ git tag my-tag fatal: tag 'my-tag' already exists $ git tag my-tag 80ab5d4 Updated tag 'my-tag' (was 9e2546a) $ git tag -f my-tag 80ab5d4 Deleted tag 'my-tag' (was 80ab5d4) $ git tag -d my-tag

Slide 148

Slide 148 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 149

Slide 149 text

Part VI: Internals In which we discover how git stores files, and are surprised how simple it all is

Slide 150

Slide 150 text

.git ├── HEAD ├── config ├── description ├── hooks │ ├── applypatch-msg.sample │ ├── ... │ └── update.sample ├── info │ └── exclude ├── objects │ ├── info │ └── pack └── refs ├── heads └── tags

Slide 151

Slide 151 text

.git ├── HEAD ├── config ├── description ├── hooks │ ├── applypatch-msg.sample │ ├── ... │ └── update.sample ├── info │ └── exclude ├── objects │ ├── info │ └── pack └── refs ├── heads └── tags

Slide 152

Slide 152 text

No content

Slide 153

Slide 153 text

No content

Slide 154

Slide 154 text

h"ps:/ /www.flickr.com/photos/rjw1/2192520114

Slide 155

Slide 155 text

Garbage collection

Slide 156

Slide 156 text

Counting objects: 17, done. Delta compression using up to 4 threads. Compressing objects: 100% (12/12), done. Writing objects: 100% (17/17), done. Total 17 (delta 8), reused 0 (delta 0) Garbage collection $ git gc

Slide 157

Slide 157 text

Counting objects: 17, done. Delta compression using up to 4 threads. Compressing objects: 100% (12/12), done. Writing objects: 100% (17/17), done. Total 17 (delta 8), reused 0 (delta 0) Garbage collection $ git gc .git/objects/pack/ ├── pack-3fcf895c12fffd5f7003b5f83f5f721495287349.idx └── pack-3fcf895c12fffd5f7003b5f83f5f721495287349.pack $ tree .git/objects/pack/

Slide 158

Slide 158 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 159

Slide 159 text

Part VII: Merge & Rebase Which is generally where the trouble starts

Slide 160

Slide 160 text

A B E F master branch C D

Slide 161

Slide 161 text

A B E F master branch git checkout master C D

Slide 162

Slide 162 text

A B E F master branch git checkout master git merge branch C D

Slide 163

Slide 163 text

A B E F master branch C D G

Slide 164

Slide 164 text

A B E F master branch C D G

Slide 165

Slide 165 text

A B E F master C D G

Slide 166

Slide 166 text

A B C D master branch

Slide 167

Slide 167 text

A B C D master branch git checkout master

Slide 168

Slide 168 text

A B C D master branch git checkout master git merge branch

Slide 169

Slide 169 text

A B C D master branch

Slide 170

Slide 170 text

A B C D master branch

Slide 171

Slide 171 text

A B C D master branch

Slide 172

Slide 172 text

A B C D master branch git checkout master

Slide 173

Slide 173 text

A B C D master branch git checkout master git merge --squash branch

Slide 174

Slide 174 text

A B C D master branch E

Slide 175

Slide 175 text

A B C D master branch

Slide 176

Slide 176 text

A B C D master branch git checkout master

Slide 177

Slide 177 text

A B C D master branch git checkout master git merge --no-ff branch

Slide 178

Slide 178 text

A B C D master branch E

Slide 179

Slide 179 text

A B E F master branch C D

Slide 180

Slide 180 text

A B E F master branch git checkout branch C D

Slide 181

Slide 181 text

A B E F master branch git checkout branch git rebase master C D

Slide 182

Slide 182 text

A B E F master branch C D

Slide 183

Slide 183 text

A B E F master branch C D E' F'

Slide 184

Slide 184 text

A B E F master branch C D E' F'

Slide 185

Slide 185 text

A B master branch C D E' F'

Slide 186

Slide 186 text

A B master branch C D E' F' git checkout master

Slide 187

Slide 187 text

A B master branch C D E' F' git checkout master git merge --ff-only branch

Slide 188

Slide 188 text

A B master branch C D E' F'

Slide 189

Slide 189 text

A B E F master branch C D

Slide 190

Slide 190 text

A B E F master branch git checkout master C D

Slide 191

Slide 191 text

A B E F master branch git checkout master git cherry-pick E C D

Slide 192

Slide 192 text

A B E F master branch C D E'

Slide 193

Slide 193 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 194

Slide 194 text

Part VIII: Distributed git In which we remember that distribution was supposed to be the whole point, and wonder why it took so long to get there

Slide 195

Slide 195 text

Clone a repository

Slide 196

Slide 196 text

Cloning into 'rspec'... remote: Counting objects: 807, done. remote: Total 807 (delta 0), reused 0 (delta 0), pack-reused 807 Receiving objects: 100% (807/807), 96.04 KiB | 20.00 KiB/s, done. Resolving deltas: 100% (308/308), done. Checking connectivity... done. Clone a repository $ git clone [email protected]:rspec/rspec.git

Slide 197

Slide 197 text

Clone a repository

Slide 198

Slide 198 text

Clone a repository $ git branch -a

Slide 199

Slide 199 text

* master remotes/origin/2-0-stable remotes/origin/2-14-maintenance remotes/origin/2-99-maintenance remotes/origin/3-0-maintenance remotes/origin/3-1-maintenance remotes/origin/3-2-maintenance remotes/origin/HEAD -> origin/master remotes/origin/experimental remotes/origin/master Clone a repository $ git branch -a

Slide 200

Slide 200 text

Local  machine Server master   branch my-­‐feature   branch clone

Slide 201

Slide 201 text

Local  machine Server master   branch my-­‐feature   branch

Slide 202

Slide 202 text

origin Local  machine Server master   branch my-­‐feature   branch

Slide 203

Slide 203 text

origin Local  machine Server master   branch my-­‐feature   branch origin/master   remote  branch origin/my-­‐feature   remote  branch

Slide 204

Slide 204 text

origin Local  machine Server master   branch my-­‐feature   branch master   branch origin/master   remote  branch origin/my-­‐feature   remote  branch

Slide 205

Slide 205 text

origin Local  machine Working   copy Server master   branch my-­‐feature   branch master   branch origin/master   remote  branch origin/my-­‐feature   remote  branch

Slide 206

Slide 206 text

Local  machine master   branch Working   copy Server master   branch my-­‐feature   branch origin/master   remote  branch origin/my-­‐feature   remote  branch fetch

Slide 207

Slide 207 text

Local  machine master   branch Working   copy Server master   branch my-­‐feature   branch origin/master   remote  branch origin/my-­‐feature   remote  branch pull

Slide 208

Slide 208 text

Local  machine master   branch Working   copy my-­‐feature   branch Server master   branch my-­‐feature   branch origin/master   remote  branch origin/my-­‐feature   remote  branch push

Slide 209

Slide 209 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 210

Slide 210 text

Part IX: Patches & email For when you don’t have direct access to the remote repository

Slide 211

Slide 211 text

Mailing patches

Slide 212

Slide 212 text

9e2546a (HEAD, master) Insert some magic into the text 80ab5d4 (origin/master) Add a file with some placeholder text Mailing patches $ git log --graph —pretty=format:'%h – %d %s'

Slide 213

Slide 213 text

9e2546a (HEAD, master) Insert some magic into the text 80ab5d4 (origin/master) Add a file with some placeholder text Mailing patches $ git log --graph —pretty=format:'%h – %d %s' 0001-Insert-some-magic-into-the-text.patch $ git format-patch origin/master

Slide 214

Slide 214 text

Mailing patches

Slide 215

Slide 215 text

From 9e2546aef0232daf56635b6319bcf69f788bd5ba Mon Sep 17 00:00:00 2001 From: Kerry Buckley Date: Sun, 8 Mar 2015 09:54:31 +0000 Subject: [PATCH] Insert some magic into the text --- foo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foo.txt b/foo.txt index e1bc2ab..d66717b 100644 --- a/foo.txt +++ b/foo.txt @@ -1,6 +1,6 @@ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis -nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +expelliarmus wingardium leviosa expecto patronum imperio crucio avada kedavra Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum -- 2.3.1 Mailing patches

Slide 216

Slide 216 text

Applying patches

Slide 217

Slide 217 text

Applying: Insert some magic into the text Applying patches $ git am 0001-Insert-some-magic-into-the-text.patch

Slide 218

Slide 218 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 219

Slide 219 text

Part X: Team Workflows In which we look for the best approach to managing shared code, and find that there’s no one true way

Slide 220

Slide 220 text

Sharing changes

Slide 221

Slide 221 text

Sharing changes Direct push/pull between repos

Slide 222

Slide 222 text

Sharing changes Direct push/pull between repos Maintainer hierarchy

Slide 223

Slide 223 text

Sharing changes Direct push/pull between repos Maintainer hierarchy Emailed patches

Slide 224

Slide 224 text

Sharing changes Direct push/pull between repos Maintainer hierarchy Emailed patches Central repo (GitHub, GitLab etc)

Slide 225

Slide 225 text

Sharing changes Direct push/pull between repos Maintainer hierarchy Emailed patches Central repo (GitHub, GitLab etc) Shared repo with commit access

Slide 226

Slide 226 text

Sharing changes Direct push/pull between repos Maintainer hierarchy Emailed patches Central repo (GitHub, GitLab etc) Shared repo with commit access Forks and pull requests

Slide 227

Slide 227 text

History on master

Slide 228

Slide 228 text

History on master Linear history

Slide 229

Slide 229 text

History on master Linear history All commits straight to master

Slide 230

Slide 230 text

History on master Linear history All commits straight to master Branch, rebase & merge

Slide 231

Slide 231 text

History on master Linear history All commits straight to master Branch, rebase & merge Branch with merge bubble

Slide 232

Slide 232 text

Part XI: Hooks By which time the audience is starting to tire of these subtitles

Slide 233

Slide 233 text

.git ├── ... ├── hooks │ ├── applypatch-msg.sample │ ├── commit-msg.sample │ ├── post-update.sample │ ├── pre-applypatch.sample │ ├── pre-commit.sample │ ├── pre-push.sample │ ├── pre-rebase.sample │ ├── prepare-commit-msg.sample │ └── update.sample └── ...

Slide 234

Slide 234 text

pre-commit prepare-commit-msg commit-msg post-commit Commit hooks

Slide 235

Slide 235 text

pre-rebase post-merge pre-push Merge & rebase hooks

Slide 236

Slide 236 text

applypatch-msg pre-applypatch post-applypatch Patch hooks

Slide 237

Slide 237 text

pre-receive update post-receive Server-side hooks

Slide 238

Slide 238 text

post-checkout post-rewrite pre-auto-gc Other hooks

Slide 239

Slide 239 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 240

Slide 240 text

Part XII: Rewriting History In which the past turns out to be more malleable than expected

Slide 241

Slide 241 text

No content

Slide 242

Slide 242 text

History-changing commands

Slide 243

Slide 243 text

git reset --hard History-changing commands

Slide 244

Slide 244 text

git reset --hard git commit --amend History-changing commands

Slide 245

Slide 245 text

git reset --hard git commit --amend git rebase History-changing commands

Slide 246

Slide 246 text

git reset --hard git commit --amend git rebase git rebase -i History-changing commands

Slide 247

Slide 247 text

Interactive rebase

Slide 248

Slide 248 text

pick 9e2546a Insert some magic into the text pick cfb3546 Add introductory line pick 2985b57 Add some hipster ipsum # Rebase 80ab5d4..2985b57 onto 80ab5d4 ( 3 TODO item(s)) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out Interactive rebase $ git rebase -i 80ab5d4

Slide 249

Slide 249 text

Pushing rewritten history

Slide 250

Slide 250 text

To /Users/kerry/masterclass ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '/Users/kerry/masterclass' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. Pushing rewritten history $ git push

Slide 251

Slide 251 text

Pushing rewritten history

Slide 252

Slide 252 text

Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 458 bytes | 0 bytes/s, done. Total 3 (delta 1), reused 0 (delta 0) To /Users/kerry/masterclass + 2985b57...055e9f6 master -> master (forced update) Pushing rewritten history $ git push -f

Slide 253

Slide 253 text

Exercise time! ©  Freepik  h"p:/ /www.flaBcon.com,  CC  BY  3.0

Slide 254

Slide 254 text

Part XIII: Working with svn In which we use git locally with legacy projects, to avoid having to touch subversion with our bare hands

Slide 255

Slide 255 text

Cloning an svn repo

Slide 256

Slide 256 text

Initialized empty Git repository in /Users/kerry/foo/.git/ Using higher level of URL: file:///Users/kerry/svn/foo => file:///Users/kerry/ svn r1 = 845504bcb16ce2004479227776b937dcab69bf23 (refs/remotes/origin/trunk) A foo.txt r2 = 16c802a2578ea71c3d96eb70cc6c5ed247883f50 (refs/remotes/origin/trunk) M foo.txt r3 = 6b3d13ce78571566341a3f1d797062afcca47adf (refs/remotes/origin/trunk) Checked out HEAD: file:///Users/kerry/svn/foo/trunk r3 Cloning an svn repo $ git svn clone -s file:///Users/kerry/svn/foo

Slide 257

Slide 257 text

Cloning an svn repo

Slide 258

Slide 258 text

commit 6b3d13ce78571566341a3f1d797062afcca47adf Author: kerry Date: 4 minutes ago Insert some magic into the text git-svn-id: file:///Users/kerry/svn/foo/trunk@3 e0cd7379-fbe6-420c-9387-2eba09531e83 commit 16c802a2578ea71c3d96eb70cc6c5ed247883f50 Author: kerry Date: 5 minutes ago Add a file with some placeholder text git-svn-id: file:///Users/kerry/svn/foo/trunk@2 e0cd7379-fbe6-420c-9387-2eba09531e83 Cloning an svn repo $ git log

Slide 259

Slide 259 text

Pulling remote changes

Slide 260

Slide 260 text

M foo.txt r4 = 6f2ed53c4d52fdbc0b1bc29b5b377518fd2db797 (refs/remotes/origin/trunk) First, rewinding head to replay your work on top of it... Applying: Add some hipster ipsum Using index info to reconstruct a base tree... M foo.txt Falling back to patching base and 3-way merge... Auto-merging foo.txt Pulling remote changes $ git svn rebase

Slide 261

Slide 261 text

Committing changes

Slide 262

Slide 262 text

Committing to file:///Users/kerry/svn/foo/trunk ... M foo.txt Committed r5 M foo.txt r5 = af3a4e909657b619b1665bc38a224ded7ff82e07 (refs/remotes/origin/trunk) No changes between 000f0660457584cccbcac635f876c7ee56ba3846 and refs/remotes/ origin/trunk Resetting to the latest refs/remotes/origin/trunk Committing changes $ git svn dcommit

Slide 263

Slide 263 text

Part XIV: Fixing Mistakes In which we discover that although git allows you to shoot yourself in the foot, it also provides bullet-proof socks

Slide 264

Slide 264 text

hPp:/ /jus5nhileman.info/git-­‐prePy/

Slide 265

Slide 265 text

No content

Slide 266

Slide 266 text

Fixing mistakes

Slide 267

Slide 267 text

Fixing mistakes Reset to last commit

Slide 268

Slide 268 text

Fixing mistakes Reset to last commit git reset --hard

Slide 269

Slide 269 text

Fixing mistakes Reset to last commit git reset --hard Forgot to commit something

Slide 270

Slide 270 text

Fixing mistakes Reset to last commit git reset --hard Forgot to commit something git commit --amend

Slide 271

Slide 271 text

Fixing mistakes Reset to last commit git reset --hard Forgot to commit something git commit --amend Redo last commit

Slide 272

Slide 272 text

Fixing mistakes Reset to last commit git reset --hard Forgot to commit something git commit --amend Redo last commit git reset HEAD~

Slide 273

Slide 273 text

Fixing mistakes

Slide 274

Slide 274 text

Fixing mistakes Put changes aside temporarily

Slide 275

Slide 275 text

Fixing mistakes Put changes aside temporarily git stash

Slide 276

Slide 276 text

Fixing mistakes Put changes aside temporarily git stash Reapply stashed changes

Slide 277

Slide 277 text

Fixing mistakes Put changes aside temporarily git stash Reapply stashed changes git stash pop

Slide 278

Slide 278 text

Fixing mistakes Put changes aside temporarily git stash Reapply stashed changes git stash pop Find out when something broke

Slide 279

Slide 279 text

Fixing mistakes Put changes aside temporarily git stash Reapply stashed changes git stash pop Find out when something broke git bisect

Slide 280

Slide 280 text

Fixing mistakes

Slide 281

Slide 281 text

Fixing mistakes Rearrange committed changes

Slide 282

Slide 282 text

Fixing mistakes Rearrange committed changes git rebase -i

Slide 283

Slide 283 text

Fixing mistakes Rearrange committed changes git rebase -i Undo a pushed commit

Slide 284

Slide 284 text

Fixing mistakes Rearrange committed changes git rebase -i Undo a pushed commit git revert

Slide 285

Slide 285 text

Fixing mistakes Rearrange committed changes git rebase -i Undo a pushed commit git revert Lost history

Slide 286

Slide 286 text

Fixing mistakes Rearrange committed changes git rebase -i Undo a pushed commit git revert Lost history git reflog

Slide 287

Slide 287 text

Exercise time! h"p:/ /www.rhoenradturnen.org/

Slide 288

Slide 288 text

The end. Any questions?