Slide 1

Slide 1 text

! Mastering Git & GitHub

Slide 2

Slide 2 text

! ben " benstraub Ben Straub

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

! What to Expect

Slide 6

Slide 6 text

! What to Expect not

Slide 7

Slide 7 text

! Git & GitHub for Ninjas

Slide 8

Slide 8 text

Git & GitHub for Ninjas

Slide 9

Slide 9 text

Shell

Slide 10

Slide 10 text

! bash

Slide 11

Slide 11 text

! zsh

Slide 12

Slide 12 text

! powershell

Slide 13

Slide 13 text

Aliases $ git config --global alias.lg log --graph \ --pretty=oneline --abbrev-commit --decorate

Slide 14

Slide 14 text

!/matthewmccullough/dotfiles/blob/master/gitconfig

Slide 15

Slide 15 text

Git Is Simple

Slide 16

Slide 16 text

Objects and Refs

Slide 17

Slide 17 text

Objects Are Easy

Slide 18

Slide 18 text

$ git cat-file -t d7abd6 blob $ git cat-file -p d7abd6 {% if page.title %}{{ page.title }} - {% endif %}{{ si Blob

Slide 19

Slide 19 text

$ git cat-file -t d7abd6 blob $ git cat-file -p d7abd6 {% if page.title %}{{ page.title }} - {% endif %}{{ si Blob

Slide 20

Slide 20 text

$ git cat-file -t d7abd6 blob $ git cat-file -p d7abd6 {% if page.title %}{{ page.title }} - {% endif %}{{ si Blob

Slide 21

Slide 21 text

$ git cat-file -t d7abd6 blob $ git cat-file -p d7abd6 {% if page.title %}{{ page.title }} - {% endif %}{{ si Blob

Slide 22

Slide 22 text

$ git cat-file -t 8f5b65 tree $ git cat-file -p 8f5b65 100644 blob 08b8e3400a81a79aeb42878171449b773ab493c0 after_foot 100644 blob 11517b315de6d7bc7550cc74ae413f1e6dafce19 archive_po 100644 blob 8ad5afd4581caa7458658325aeec9f8de875b988 article.ht 040000 tree 5c2166adaa57c909182a45b995dfb750c22c8810 asides 040000 tree 52deb7c58d46aa09208c0b863fbecee81a2e3dad custom 100644 blob eb308779fa09eadd8575b1acea2801f16ef1d839 disqus.htm 100644 blob 74f91307278c092bca1e862337cb8d2b1ac14d94 facebook_l 100644 blob 3a8c7687474e513b196b50f5634c6decd14ed484 footer.htm Tree

Slide 23

Slide 23 text

Commit $ git cat-file -t e365b187 commit $ git cat-file -p e365b187 tree 58c796e7717809c2ca2217fc5424fdebdbc121b1 parent d4291dfddfae86cfacec789133861098cebc67d4 author Ben Straub 1380719530 -0700 committer Ben Straub 1380719530 -0700 ! Fix typo, remove false statement

Slide 24

Slide 24 text

Tag Annotation $ git cat-file -t 849a5e34a tag $ git cat-file -p 849a5e34a object a65fedf39aefe402d3bb6e24df4d4f5fe4547750 type commit tag hard_tag tagger Ben Straub Fri May 11 11:47:58 2012 ! Tag on tag

Slide 25

Slide 25 text

Refs are Easy

Slide 26

Slide 26 text

* * | * | | * | | * | | * | | |\ | |/ / |/| | | | | * | | | * | | | * | | |/ | |/| | * | | |\ \ | |/ / |/| / | |/ * | | * | * |/ * * Refs are Easy

Slide 27

Slide 27 text

* * | * | | * | | * | | * | | |\ | |/ / |/| | | | | * | | | * | | | * | | |/ | |/| | * | | |\ \ | |/ / |/| / | |/ * | | * | * |/ * * Refs are Easy

Slide 28

Slide 28 text

$ cat refs/heads/master 2b67270f960563c55dd6c66495517bccc4f7fb17 Branches

Slide 29

Slide 29 text

$ cat refs/tags/v0.19.0 eddc1f1ed78898a4ca41480045b1d0d5b075e773 Tags

Slide 30

Slide 30 text

$ cat HEAD ref: refs/heads/master Symbolic Refs

Slide 31

Slide 31 text

Symbolic Refs • branch -> commit • HEAD -> branch -> commit • tag -> commit • tag -> annotation -> commit • tag -> blob • HEAD -> branch -> tag -> annotation1 -> annotation2 -> blob • WAT

Slide 32

Slide 32 text

Git Is Simple?

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Three Trees

Slide 35

Slide 35 text

HEAD Last Commit Next Parent

Slide 36

Slide 36 text

Index Proposed Next Commit

Slide 37

Slide 37 text

Working Directory Sandbox

Slide 38

Slide 38 text

Moving Things Around • Sandbox -> Index: git add • Index -> History: git commit • History -> Index/Sandbox: git checkout

Slide 39

Slide 39 text

git reset is Weird

Slide 40

Slide 40 text

Reset 1. Move HEAD
 (Stop here if --soft) 2. Make the index look like HEAD
 (Stop here if --mixed, which is the default) 3.Make the sandbox look like the index
 (Stop here if --hard)

Slide 41

Slide 41 text

Bisect

Slide 42

Slide 42 text

$ ./new_test.sh BAD THINGS $ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed Initial commit $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step

Slide 43

Slide 43 text

$ ./new_test.sh BAD THINGS $ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed Initial commit $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step

Slide 44

Slide 44 text

$ ./new_test.sh BAD THINGS $ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed Initial commit $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step

Slide 45

Slide 45 text

$ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed Initial commit $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change

Slide 46

Slide 46 text

$ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd (HEAD) Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ ./new_test.sh ALL CLEAR $ git bisect good Bisecting: 0 revisions left to test after this (roughly 1 step

Slide 47

Slide 47 text

$ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd (HEAD) Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ ./new_test.sh ALL CLEAR $ git bisect good Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! $ git lga

Slide 48

Slide 48 text

$ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd (HEAD) Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ ./new_test.sh ALL CLEAR $ git bisect good Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! $ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc (HEAD) Great justice! * 2e36522 Some innocent change

Slide 49

Slide 49 text

$ ./new_test.sh ALL CLEAR $ git bisect good Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! $ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc (HEAD) Great justice! * 2e36522 Some innocent change * bf4a9fd (refs/bisect/good-bf4a9fdc7ca066fd132f79e8607d7fda81 * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ ./new_test.sh BAD THINGS $ git bisect bad Bisecting: 0 revisions left to test after this (roughly 0 step

Slide 50

Slide 50 text

$ git lga * 394fe77 (master, refs/bisect/bad) MOAR DOTS * 155cfdc (HEAD) Great justice! * 2e36522 Some innocent change * bf4a9fd (refs/bisect/good-bf4a9fdc7ca066fd132f79e8607d7fda81 * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ ./new_test.sh BAD THINGS $ git bisect bad Bisecting: 0 revisions left to test after this (roughly 0 step [2e3652251ca60b394dd6dd58b35aad2c68341b81] Some innocent chang $ ./new_test.sh BAD THINGS $ git bisect bad 2e3652251ca60b394dd6dd58b35aad2c68341b81 is the first bad comm

Slide 51

Slide 51 text

Bisecting: 0 revisions left to test after this (roughly 0 step [2e3652251ca60b394dd6dd58b35aad2c68341b81] Some innocent chang $ ./new_test.sh BAD THINGS $ git bisect bad 2e3652251ca60b394dd6dd58b35aad2c68341b81 is the first bad comm commit 2e3652251ca60b394dd6dd58b35aad2c68341b81 Author: Me Date: Sat Sep 8 21:07:23 2012 -0700 ! Some innocent change ! :100644 100644 cffc75085d348cd4f418fc4d4257df03eb8c3c15 4d95ce $ git show commit 2e3652251ca60b394dd6dd58b35aad2c68341b81 Author: Me Date: Sat Sep 8 21:07:23 2012 -0700

Slide 52

Slide 52 text

Some innocent change ! diff --git a/critical.txt b/critical.txt index cffc750..4d95ced 100644 --- a/critical.txt +++ b/critical.txt @@ -2,5 +2,6 @@ GOOD GOOD GOOD GOOD +EVIL MUAHAHAHAHA GOOD GOOD $ git lga * 394fe77 (master) MOAR DOTS * 155cfdc Great justice! * 2e36522 (HEAD, refs/bisect/bad) Some innocent change

Slide 53

Slide 53 text

GOOD GOOD +EVIL MUAHAHAHAHA GOOD GOOD $ git lga * 394fe77 (master) MOAR DOTS * 155cfdc Great justice! * 2e36522 (HEAD, refs/bisect/bad) Some innocent change * bf4a9fd (refs/bisect/good-bf4a9fdc7ca066fd132f79e8607d7fda81 * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ git bisect reset Previous HEAD position was 2e36522... Some innocent change Switched to branch 'master' $ git lga

Slide 54

Slide 54 text

GOOD GOOD $ git lga * 394fe77 (master) MOAR DOTS * 155cfdc Great justice! * 2e36522 (HEAD, refs/bisect/bad) Some innocent change * bf4a9fd (refs/bisect/good-bf4a9fdc7ca066fd132f79e8607d7fda81 * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ git bisect reset Previous HEAD position was 2e36522... Some innocent change Switched to branch 'master' $ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change

Slide 55

Slide 55 text

* f4fb4ef Work on feature #72 * 2b241ed (refs/bisect/good-2b241ed06235b4ccbdf7dabae47b5c9f58 $ git bisect reset Previous HEAD position was 2e36522... Some innocent change Switched to branch 'master' $ git lga * 394fe77 (HEAD, master) MOAR DOTS * 155cfdc Great justice! * 2e36522 Some innocent change * bf4a9fd Fixed configuration * 713d64c Fixed bug #718 * f4fb4ef Work on feature #72 * 2b241ed Initial commit

Slide 56

Slide 56 text

$ ./new_test.sh BAD THINGS $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git bisect run ./new_test.sh running ./new_test.sh ALL CLEAR Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! running ./new_test.sh BAD THINGS

Slide 57

Slide 57 text

$ ./new_test.sh BAD THINGS $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git bisect run ./new_test.sh running ./new_test.sh ALL CLEAR Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! running ./new_test.sh BAD THINGS

Slide 58

Slide 58 text

$ ./new_test.sh BAD THINGS $ git bisect start $ git bisect good 2b241 $ git bisect bad Bisecting: 2 revisions left to test after this (roughly 2 step [bf4a9fdc7ca066fd132f79e8607d7fda81bc9ac7] Fixed configuration $ git bisect run ./new_test.sh running ./new_test.sh ALL CLEAR Bisecting: 0 revisions left to test after this (roughly 1 step [155cfdc11389c013609c75f5d3dd4e834f0c7f39] Great justice! running ./new_test.sh BAD THINGS

Slide 59

Slide 59 text

running ./new_test.sh BAD THINGS Bisecting: 0 revisions left to test after this (roughly 0 step [2e3652251ca60b394dd6dd58b35aad2c68341b81] Some innocent chang running ./new_test.sh BAD THINGS 2e3652251ca60b394dd6dd58b35aad2c68341b81 is the first bad comm commit 2e3652251ca60b394dd6dd58b35aad2c68341b81 Author: Me Date: Sat Sep 8 21:07:23 2012 -0700 ! Some innocent change ! :100644 100644 cffc75085d348cd4f418fc4d4257df03eb8c3c15 4d95ce bisect run success $ !

Slide 60

Slide 60 text

Rebase Rebase

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

Don’t Overwrite Remote History

Slide 83

Slide 83 text

But if You Do git pull --rebase

Slide 84

Slide 84 text

Filter-Branch

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

var rewriteHistoryOptions = new RewriteHistoryOptions { CommitTreeRewriter = c => TreeDefinition.From(c).Remove("README"), CommitHeaderRewriter = c => CommitRewriteInfo.From(c, message: "HEYOOOO"), }; repo.Refs.RewriteHistory(rewriteHistoryOptions, repo.Head.Commits); Parlez-vous C#?

Slide 104

Slide 104 text

Git & GitHub for Ninjas

Slide 105

Slide 105 text

! Git & GitHub for Ninjas

Slide 106

Slide 106 text

! Hub

Slide 107

Slide 107 text

! Hub Teaches Git about GitHub

Slide 108

Slide 108 text

! Fancy Cloning git clone https://github.com/mojombo/jekyll hub clone mojombo/jekyll

Slide 109

Slide 109 text

! Issue # Pull Request hub pull-request -i

Slide 110

Slide 110 text

! The Best Way alias git=hub

Slide 111

Slide 111 text

! Get It http://hub.github.com/

Slide 112

Slide 112 text

! Pull Requests

Slide 113

Slide 113 text

! From a Fork

Slide 114

Slide 114 text

! From a Fork

Slide 115

Slide 115 text

! From a Fork

Slide 116

Slide 116 text

! From a Fork

Slide 117

Slide 117 text

! From a Fork

Slide 118

Slide 118 text

! From a Fork

Slide 119

Slide 119 text

! From Not a Fork

Slide 120

Slide 120 text

! Not Just For Finished Code

Slide 121

Slide 121 text

!

Slide 122

Slide 122 text

!

Slide 123

Slide 123 text

!

Slide 124

Slide 124 text

!

Slide 125

Slide 125 text

!

Slide 126

Slide 126 text

!

Slide 127

Slide 127 text

! Markdown

Slide 128

Slide 128 text

No content

Slide 129

Slide 129 text

No content

Slide 130

Slide 130 text

! Emoji :sunset: ! :clap: ! :cookie: ! :poop: ! :sheep::dash:

Slide 131

Slide 131 text

! Emoji http://www.emoji-cheat-sheet.com/

Slide 132

Slide 132 text

No content

Slide 133

Slide 133 text

⌘+shift+P   ctrl+shift+P

Slide 134

Slide 134 text

No content

Slide 135

Slide 135 text

! Closing Issues Spooky Action at a Distance

Slide 136

Slide 136 text

! With Commits

Slide 137

Slide 137 text

! With Pull Requests

Slide 138

Slide 138 text

! Mentions

Slide 139

Slide 139 text

! Summon a Person @ben, what do you think?

Slide 140

Slide 140 text

! Or a Team @github/dotcom, what do you think?

Slide 141

Slide 141 text

! Or a Team @github/legal, what do you think?

Slide 142

Slide 142 text

! Or Something Else @github/javascript, what do you think?

Slide 143

Slide 143 text

! Or Something Else @github/design, what do you think?

Slide 144

Slide 144 text

! Or Something Else @github/refactoring, what do you think?

Slide 145

Slide 145 text

! Or Something Else @github/colorblind, what do you think?

Slide 146

Slide 146 text

! Non-Code Repos

Slide 147

Slide 147 text

No content

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

! Clients

Slide 150

Slide 150 text

Use the Shell

Slide 151

Slide 151 text

GitHub Mac

Slide 152

Slide 152 text

GitHub Windows

Slide 153

Slide 153 text

Full Clients http://git-scm.com/downloads/guis

Slide 154

Slide 154 text

The Weird Stuff

Slide 155

Slide 155 text

$

Slide 156

Slide 156 text

! http://git.io/LuPVlg