$30 off During Our Annual Pro Sale. View Details »

Git's Meat Cleavers

Git's Meat Cleavers

This is the talk I gave at php|arch's online Git Summit.

Please note that the slides are minimal. This is best used for reference along with the video of the slide available at: http://www.phparch.com/phparchitect-live-presents-the-virtual-git-summit/

Travis Swicegood

February 01, 2012
Tweet

More Decks by Travis Swicegood

Other Decks in Programming

Transcript

  1. Git’s Meat Cleavers Travis Swicegood Licensed under Creative Commons, Attribution,

    Share-Alike
  2. some rights reserved git’s meat cleavers by travis swicegood Hi,

    I’m Travis
  3. some rights reserved git’s meat cleavers by travis swicegood

  4. some rights reserved git’s meat cleavers by travis swicegood #gittalk

  5. some rights reserved git’s meat cleavers by travis swicegood What’s

    this talk about?
  6. some rights reserved git’s meat cleavers by travis swicegood Amending

  7. some rights reserved git’s meat cleavers by travis swicegood Rebasing

  8. some rights reserved git’s meat cleavers by travis swicegood Interactive

    Rebasing
  9. some rights reserved git’s meat cleavers by travis swicegood Fixing

    the First Commit
  10. some rights reserved git’s meat cleavers by travis swicegood Rebase

    Onto
  11. some rights reserved git’s meat cleavers by travis swicegood Bisecting

    Repos
  12. some rights reserved git’s meat cleavers by travis swicegood Warning

  13. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  14. some rights reserved git’s meat cleavers by travis swicegood Amending

  15. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git commit --amend \ > [normal options] … use previous message as template … prompt> git commit --amend -c HEAD … use previous message w/o prompt … prompt> git commit --amend -C HEAD Command
  16. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git commit --amend \ > [normal options] … use previous message as template … prompt> git commit --amend -c HEAD … use previous message w/o prompt … prompt> git commit --amend -C HEAD Command
  17. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git commit --amend \ > [normal options] … use previous message as template … prompt> git commit --amend -c HEAD … use previous message w/o prompt … prompt> git commit --amend -C HEAD Command
  18. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git config --global \ > alias.amend "commit --amend" … use previous message as template … prompt> git commit --amend -c HEAD … use previous message w/o prompt … prompt> git commit --amend -C HEAD #protip
  19. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git config --global \ > alias.amend "commit --amend" … use previous message as template … prompt> git commit --amend -c HEAD … use previous message w/o prompt … prompt> git commit --amend -C HEAD #protip
  20. some rights reserved git’s meat cleavers by travis swicegood prompt>

    git config --global \ > alias.amend "commit --amend" … use previous message as template … prompt> git amend -c HEAD … use previous message w/o prompt … prompt> git amend -C HEAD #protip
  21. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  22. some rights reserved git’s meat cleavers by travis swicegood Rebasing

  23. some rights reserved git’s meat cleavers by travis swicegood The

    Repository prompt> git log --oneline --graph --all * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  24. some rights reserved git’s meat cleavers by travis swicegood Replay

    These prompt> git log --oneline --graph --all * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  25. some rights reserved git’s meat cleavers by travis swicegood On

    Top of This prompt> git log --oneline --graph --all * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  26. some rights reserved git’s meat cleavers by travis swicegood The

    Repository prompt> git log --oneline --graph --all * ce38ccb commit message f <- master | * 5a2eaf3 commit message e <- other | * 5a00102 commit message d |/ * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  27. some rights reserved git’s meat cleavers by travis swicegood Switch

    Branches prompt> git checkout other Switched to branch 'other' prompt> git rebase master First, rewinding head to replay your work on top of it... Applying: commit message d Applying: commit message e
  28. some rights reserved git’s meat cleavers by travis swicegood Command

    prompt> git checkout other Switched to branch 'other' prompt> git rebase master First, rewinding head to replay your work on top of it... Applying: commit message d Applying: commit message e
  29. some rights reserved git’s meat cleavers by travis swicegood The

    Result prompt> git log --oneline --graph --all * cb199f5 commit message e * 98f457f commit message d * ce38ccb commit message f * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  30. some rights reserved git’s meat cleavers by travis swicegood The

    Result prompt> git log --oneline --graph --all * cb199f5 commit message e * 98f457f commit message d * ce38ccb commit message f * 2b449a0 commit message c * 1674c67 commit message b * 0f5f8d0 commit message a
  31. some rights reserved pragmatic guide to git by travis swicegood

    I’m Not Telling the Whole Truth
  32. some rights reserved git’s meat cleavers by travis swicegood The

    Full Result prompt> git log --oneline --graph --all * cb199f5 commit message e * 98f457f commit message d * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c …
  33. some rights reserved git’s meat cleavers by travis swicegood The

    Full Result prompt> git log --oneline --graph --all * cb199f5 commit message e * 98f457f commit message d * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c …
  34. some rights reserved git’s meat cleavers by travis swicegood These

    IDs Don’t Match! prompt> git log --oneline --graph --all * cb199f5 commit message e * 98f457f commit message d * ce38ccb commit message f | * 5a2eaf3 commit message e | * 5a00102 commit message d |/ * 2b449a0 commit message c …
  35. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  36. some rights reserved git’s meat cleavers by travis swicegood Interactive

    Rebasing
  37. some rights reserved git’s meat cleavers by travis swicegood How

    To Fix 069fb4f prompt> git log --oneline 1aae0c6 Add Express example 069fb4f Say Hello World! c9161f3 add in a readme file
  38. some rights reserved git’s meat cleavers by travis swicegood Command

    prompt> git rebase -i c9161f3 … launches editor … pick 069fb4f Say Hello World! pick 1aae0c6 Add Express example # … instructions from Git here … ~ ~
  39. some rights reserved git’s meat cleavers by travis swicegood Inside

    the Editor prompt> git rebase -i c9161f3 … launches editor … pick 069fb4f Say Hello World! pick 1aae0c6 Add Express example # … instructions from Git here … ~ ~
  40. some rights reserved git’s meat cleavers by travis swicegood Inside

    the Editor prompt> git rebase -i c9161f3 … launches editor … pick 069fb4f Say Hello World! pick 1aae0c6 Add Express example # … instructions from Git here … ~ ~
  41. some rights reserved git’s meat cleavers by travis swicegood Inside

    the Editor prompt> git rebase -i c9161f3 … launches editor … edit 069fb4f Say Hello World! pick 1aae0c6 Add Express example # … instructions from Git here … ~ ~
  42. some rights reserved pragmatic guide to git by travis swicegood

    Save and Exit
  43. some rights reserved git’s meat cleavers by travis swicegood Rebase,

    Paused prompt> git log --oneline 069fb4f Say Hello World! c9161f3 add in a readme file
  44. some rights reserved pragmatic guide to git by travis swicegood

    Make Fixes
  45. some rights reserved git’s meat cleavers by travis swicegood Amend

    Commit prompt> git add server.js prompt> git commit -C HEAD --amend [detached HEAD 369bcc1] Say Hello World! 1 files changed, 8 insertions(+), 0 del… create mode 100644 server.js prompt> git rebase --continue Successfully rebased and updated refs/he…
  46. some rights reserved git’s meat cleavers by travis swicegood Or,

    Amend Commit prompt> git add server.js prompt> git amend -C HEAD [detached HEAD 369bcc1] Say Hello World! 1 files changed, 8 insertions(+), 0 del… create mode 100644 server.js prompt> git rebase --continue Successfully rebased and updated refs/he…
  47. some rights reserved git’s meat cleavers by travis swicegood Continue

    Rebasing prompt> git add server.js prompt> git amend -C HEAD [detached HEAD 369bcc1] Say Hello World! 1 files changed, 8 insertions(+), 0 del… create mode 100644 server.js prompt> git rebase --continue Successfully rebased and updated refs/he…
  48. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  49. some rights reserved git’s meat cleavers by travis swicegood Fixing

    the First Commit
  50. some rights reserved git’s meat cleavers by travis swicegood The

    Repository prompt> git log --oneline 61eaef8 fix readme (rebase) e71b6b1 Say Hello World! 5c04b11 add in a readme file
  51. some rights reserved git’s meat cleavers by travis swicegood Fixup

    the First Commit? prompt> git rebase -i 5c04b11 … launch editor, set to … fixup 61eaef8 fix readme (rebase) pick e71b6b1 Say Hello World! … save and exit … Cannot 'fixup' without a previous commit
  52. some rights reserved git’s meat cleavers by travis swicegood Fixup

    the First Commit? prompt> git rebase -i 5c04b11 … launch editor, set to … fixup 61eaef8 fix readme (rebase) pick e71b6b1 Say Hello World! … save and exit … Cannot 'fixup' without a previous commit
  53. some rights reserved git’s meat cleavers by travis swicegood Oops

    prompt> git rebase -i 5c04b11 … launch editor, set to … fixup 61eaef8 fix readme (rebase) pick e71b6b1 Say Hello World! … save and exit … Cannot 'fixup' without a previous commit
  54. some rights reserved git’s meat cleavers by travis swicegood First

    Step prompt> git rebase -i 5c04b11 … launch editor, set to … edit 61eaef8 fix readme (rebase) pick e71b6b1 Say Hello World! … save and exit …
  55. some rights reserved git’s meat cleavers by travis swicegood The

    Repository, Now prompt> git log --oneline 61eaef8 fix readme (rebase) 5c04b11 add in a readme file
  56. some rights reserved git’s meat cleavers by travis swicegood Fixing

    the Commit prompt> git reset HEAD^ prompt> git commit -C HEAD --amend -a … now the first commit is fixed … prompt> git rebase --continue
  57. some rights reserved git’s meat cleavers by travis swicegood Fixing

    the Commit prompt> git reset HEAD^ prompt> git commit -C HEAD --amend -a … now the first commit is fixed … prompt> git rebase --continue
  58. some rights reserved git’s meat cleavers by travis swicegood Fixing

    the Commit prompt> git reset HEAD^ prompt> git commit -C HEAD --amend -a … now the first commit is fixed … prompt> git rebase --continue … now last commit is replayed …
  59. some rights reserved git’s meat cleavers by travis swicegood The

    Final Repository prompt> git log --oneline 11036a0 Say Hello World! ca4bde5 add in a readme file
  60. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  61. some rights reserved git’s meat cleavers by travis swicegood Rebase

    Onto
  62. some rights reserved git’s meat cleavers by travis swicegood The

    Repository prompt> git log --oneline f99f200 commit message f ff6770a commit message e c8ceb23 commit message d 84cbfcc commit message c c14fc62 commit message b 73fffed commit message a 9883b11 README driven development
  63. some rights reserved git’s meat cleavers by travis swicegood The

    Idea prompt> git log --oneline f99f200 commit message f ff6770a commit message e <-\ c8ceb23 commit message d | 84cbfcc commit message c <-/ c14fc62 commit message b 73fffed commit message a 9883b11 README driven development
  64. some rights reserved git’s meat cleavers by travis swicegood The

    Idea prompt> git log --oneline f99f200 commit message f ff6770a commit message e c8ceb23 commit message d <- gone 84cbfcc commit message c c14fc62 commit message b 73fffed commit message a 9883b11 README driven development
  65. some rights reserved git’s meat cleavers by travis swicegood Command

    prompt> git rebase --onto HEAD^^^ \ > HEAD^^ master First, rewinding head to replay your wor… Applying: e Applying: f
  66. some rights reserved git’s meat cleavers by travis swicegood The

    Idea, Annotated prompt> git log --oneline f99f200 commit message f <- master ff6770a commit message e c8ceb23 commit message d <- HEAD^^ 84cbfcc commit message c <- HEAD^^^ c14fc62 commit message b 73fffed commit message a 9883b11 README driven development
  67. some rights reserved git’s meat cleavers by travis swicegood Where

    We’re Going To prompt> git rebase --onto HEAD^^^ \ > HEAD^^ master First, rewinding head to replay your wor… Applying: e Applying: f
  68. some rights reserved git’s meat cleavers by travis swicegood Start

    After This Point prompt> git rebase --onto HEAD^^^ \ > HEAD^^ master First, rewinding head to replay your wor… Applying: e Applying: f
  69. some rights reserved git’s meat cleavers by travis swicegood Go

    Thru This Point prompt> git rebase --onto HEAD^^^ \ > HEAD^^ master First, rewinding head to replay your wor… Applying: e Applying: f
  70. some rights reserved git’s meat cleavers by travis swicegood The

    Repository, Now prompt> git log --oneline --all * a00f953 commit message f * 04c5687 commit message e | * c8ceb23 commit message d |/ * 84cbfcc commit message c * c14fc62 commit message b * 73fffed a …
  71. some rights reserved git’s meat cleavers by travis swicegood The

    Repository, Now prompt> git log --oneline --all * a00f953 commit message f * 04c5687 commit message e | * c8ceb23 commit message d <- “removed” |/ * 84cbfcc commit message c * c14fc62 commit message b * 73fffed a …
  72. some rights reserved git’s meat cleavers by travis swicegood Once

    More, w/Branches prompt> git reset --hard ORIG_HEAD … goes back before the rebase … prompt> git branch other c8ceb23 prompt> git rebase --onto 84cbfcc \ > other master
  73. some rights reserved git’s meat cleavers by travis swicegood Once

    More, w/Branches prompt> git reset --hard ORIG_HEAD … goes back before the rebase … prompt> git branch other c8ceb23 prompt> git rebase --onto 84cbfcc \ > other master
  74. some rights reserved git’s meat cleavers by travis swicegood Once

    More, w/Branches prompt> git reset --hard ORIG_HEAD … goes back before the rebase … prompt> git branch other c8ceb23 prompt> git rebase --onto 84cbfcc \ > other master
  75. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  76. some rights reserved git’s meat cleavers by travis swicegood Bisecting

    Repos
  77. some rights reserved git’s meat cleavers by travis swicegood Where’d

    D Go? prompt> git log --oneline c2806e0 commit message g 192e360 commit message f 8ca9d5e remove commit message d 20b7062 commit message e 8539d59 commit message d … rest of the log …
  78. some rights reserved git’s meat cleavers by travis swicegood Where’d

    D Go? prompt> git log --oneline c2806e0 commit message g <- bad 192e360 commit message f 8ca9d5e remove commit message d 20b7062 commit message e 8539d59 commit message d <- good … rest of the log …
  79. some rights reserved git’s meat cleavers by travis swicegood Testing

    For D #!/bin/bash [[ -f d ]] && echo "ok" … success … $ ./test-repo ok <- exit code 0 … failure … $ ./test-repo <- exit code 1
  80. some rights reserved git’s meat cleavers by travis swicegood Testing

    For D #!/bin/bash [[ -f d ]] && echo "ok" $ ./test-repo … success … ok <- exit code 0 … failure … $ ./test-repo <- exit code 1
  81. some rights reserved git’s meat cleavers by travis swicegood Testing

    For D #!/bin/bash [[ -f d ]] && echo "ok" … success … $ ./test-repo ok <- exit code 0 … failure … $ ./test-repo <- exit code 1
  82. some rights reserved git’s meat cleavers by travis swicegood Starting

    the Bisect prompt> git bisect start HEAD 8539d59 Already on 'master' Bisecting: 1 revision left to test after this (roughly 1 step) [8ca9d5e] remove d
  83. some rights reserved git’s meat cleavers by travis swicegood Starting

    the Bisect prompt> git log --oneline c2806e0 commit message g <- bad 192e360 commit message f 8ca9d5e remove commit message d 20b7062 commit message e 8539d59 commit message d <- good … rest of the log …
  84. some rights reserved git’s meat cleavers by travis swicegood Starting

    the Bisect prompt> git bisect start <bad> 8539d59 Already on 'master' Bisecting: 1 revision left to test after this (roughly 1 step) [8ca9d5e] remove d
  85. some rights reserved git’s meat cleavers by travis swicegood Starting

    the Bisect prompt> git bisect start HEAD <good> Already on 'master' Bisecting: 1 revision left to test after this (roughly 1 step) [8ca9d5e] remove d
  86. some rights reserved git’s meat cleavers by travis swicegood Testing

    the Commit prompt> git bisect run ../test-repo running ../test-repo Bisecting: 0 revisions left to test afte… [20b7062] e running ../test-repo ok 8ca9d5e is the first bad commit
  87. some rights reserved git’s meat cleavers by travis swicegood Bisect

    Found It prompt> git log --oneline c2806e0 commit message g <- bad 192e360 commit message f 8ca9d5e remove commit message d <–1st bad 20b7062 commit message e 8539d59 commit message d <- good … rest of the log …
  88. some rights reserved pragmatic guide to git by travis swicegood

    Figure Out How-to Fix It
  89. some rights reserved git’s meat cleavers by travis swicegood Go

    Back to HEAD prompt> git bisect reset
  90. some rights reserved git’s meat cleavers by travis swicegood …

    Questions?
  91. some rights reserved git’s meat cleavers by travis swicegood Where

    To?
  92. some rights reserved git’s meat cleavers by travis swicegood git-scm.com

    #git (freenode)
  93. some rights reserved git’s meat cleavers by travis swicegood Warning

  94. some rights reserved git’s meat cleavers by travis swicegood Travis

    Swicegood travisswicegood.com @tswicegood travis@domain51.com