Slide 1

Slide 1 text

gitbeyond the basics Thursday, August 2, 12

Slide 2

Slide 2 text

John Bohn @jjbohn Thursday, August 2, 12

Slide 3

Slide 3 text

Developer at OpenSky curated social commerce Thursday, August 2, 12

Slide 4

Slide 4 text

git what is Thursday, August 2, 12

Slide 5

Slide 5 text

git is fast and lightweight free/open source distributed crazy simple Thursday, August 2, 12

Slide 6

Slide 6 text

init branch add commit merge Thursday, August 2, 12

Slide 7

Slide 7 text

Almost any VCS works does this (more or less) What is special about git? Thursday, August 2, 12

Slide 8

Slide 8 text

Interactivity Thursday, August 2, 12

Slide 9

Slide 9 text

git add --patch git add --interactive Thursday, August 2, 12

Slide 10

Slide 10 text

Arduino Example Thursday, August 2, 12

Slide 11

Slide 11 text

Change Blink Thursday, August 2, 12

Slide 12

Slide 12 text

Change Blink - Two logical changes - Don’t want to bother undoing one - Can’t git add . or git add [file] Thursday, August 2, 12

Slide 13

Slide 13 text

git add --patch Thursday, August 2, 12

Slide 14

Slide 14 text

git add --patch Thursday, August 2, 12

Slide 15

Slide 15 text

git add --patch Thursday, August 2, 12

Slide 16

Slide 16 text

git add --patch Commit the change Thursday, August 2, 12

Slide 17

Slide 17 text

git add --patch Stage other changes Diff is now empty (everything is staged or commited) Thursday, August 2, 12

Slide 18

Slide 18 text

git stash Thursday, August 2, 12

Slide 19

Slide 19 text

is super boring Thursday, August 2, 12

Slide 20

Slide 20 text

until you throw some flags at it... Thursday, August 2, 12

Slide 21

Slide 21 text

git stash --no-keep-index git stash --keep-index git stash --patch git stash --include-untracked My Favorites Thursday, August 2, 12

Slide 22

Slide 22 text

Finding these commands is just a matter of digging Thursday, August 2, 12

Slide 23

Slide 23 text

git anything --help Thursday, August 2, 12

Slide 24

Slide 24 text

git reset is not git revert Thursday, August 2, 12

Slide 25

Slide 25 text

git reset --soft [sha] git reset --hard [sha] git reset --mixed [sha] Thursday, August 2, 12

Slide 26

Slide 26 text

You can also: git reset --patch (but not with those modes) Thursday, August 2, 12

Slide 27

Slide 27 text

Bisecting aka: Finding a commit that screwed things up. Thursday, August 2, 12

Slide 28

Slide 28 text

Bisecting Thursday, August 2, 12

Slide 29

Slide 29 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 6 Commits - One Bug We know that 7b35b is good We know that cfc332 is bad But we have no idea where the bug was introduced cfc332 Thursday, August 2, 12

Slide 30

Slide 30 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 Tell git what is known good and bad cfc332 good bad Thursday, August 2, 12

Slide 31

Slide 31 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad Thursday, August 2, 12

Slide 32

Slide 32 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good Thursday, August 2, 12

Slide 33

Slide 33 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good good Thursday, August 2, 12

Slide 34

Slide 34 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good good 2ab1f is most likely good because the commit after it is Thursday, August 2, 12

Slide 35

Slide 35 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good good bad Thursday, August 2, 12

Slide 36

Slide 36 text

Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good good bad bad Thursday, August 2, 12

Slide 37

Slide 37 text

Recovering lost commits Thursday, August 2, 12

Slide 38

Slide 38 text

git reflog Thursday, August 2, 12

Slide 39

Slide 39 text

git reflog Technically shows any action where the tip of a branch is modified git reflog --all shows stashes, bisects, etc. Thursday, August 2, 12

Slide 40

Slide 40 text

Recovery Let’s say I reset --hard and wiped out the commit that changed my LED to pin 10 Use combination of reflog and cherry-pick to get it back Thursday, August 2, 12

Slide 41

Slide 41 text

Recovery Found it! 3ecdba3 Thursday, August 2, 12

Slide 42

Slide 42 text

Recovery Double check that 3ecdba3 is really the commit we want git diff 3ecdba3^.. 3ecdba3 Shows me the difference between the commit I want to cherry pick and the commit prior. Thursday, August 2, 12

Slide 43

Slide 43 text

git cherry-pick Now cherry pick 3ecdba3 into our working tree Note: the sha has changed because this commit now has a different parent than it did when it was recorded into the reflog Thursday, August 2, 12

Slide 44

Slide 44 text

Recovery Checkout the reflog again to see the cherry-pick Thursday, August 2, 12

Slide 45

Slide 45 text

Interactive Rebasing Changing the past one commit at a time Thursday, August 2, 12

Slide 46

Slide 46 text

git rebase -i [commit] Thursday, August 2, 12

Slide 47

Slide 47 text

git rebase -i [commit] Thursday, August 2, 12

Slide 48

Slide 48 text

git rebase -i [commit] Thursday, August 2, 12

Slide 49

Slide 49 text

git rebase -i [commit] Thursday, August 2, 12

Slide 50

Slide 50 text

Interactive rebase Thursday, August 2, 12

Slide 51

Slide 51 text

git internals The plumbing and the porcelain Thursday, August 2, 12

Slide 52

Slide 52 text

git internals git stores snapshots, not differences Storing differences is slow and inflexible CVS/Subversion git Thursday, August 2, 12

Slide 53

Slide 53 text

git internals git stores snapshots, not differences Storing differences is slow and inflexible CVS/Subversion git Thursday, August 2, 12

Slide 54

Slide 54 text

git internals What does a commit look like? Thursday, August 2, 12

Slide 55

Slide 55 text

git internals Let’s investigate a repo Sorry for the bad “investigation” image ;-) Thursday, August 2, 12

Slide 56

Slide 56 text

Thanks! Come work with me at OpenSky! We’re Hiring Thursday, August 2, 12