Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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 …
  16. 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 …
  17. 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 …
  18. 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
  19. 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 … ~ ~
  20. 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 … ~ ~
  21. 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 … ~ ~
  22. 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 … ~ ~
  23. 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
  24. 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…
  25. 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…
  26. 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…
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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 …
  32. 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
  33. 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
  34. 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
  35. 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 …
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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 …
  46. 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 …
  47. 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
  48. 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
  49. 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
  50. 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 …
  51. 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 …
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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 …
  57. 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
  58. 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
  59. 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
  60. 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 …