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

Debug Code and Rewrite History with Git

Debug Code and Rewrite History with Git

A short talk about how to use git bisect, interactive rebase, and git reflog for the first Dev O'Clock HVTech meetup.

Eileen M. Uchitelle

September 10, 2015
Tweet

More Decks by Eileen M. Uchitelle

Other Decks in Technology

Transcript

  1. Short (50 chars or less) summary of changes More detailed

    explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. Further paragraphs come after blank lines. - Bullet points are okay, too - Typically a hyphen or asterisk is used for the bullet, preceded by a single space, with blank lines in between, but conventions vary here
  2. GIT

  3. 1 pick e92e34f Refactor existing code 2 pick 80601e8 Oops

    add in missing code 3 pick 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 pick 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  4. 1 pick e92e34f Refactor existing code 2 pick 80601e8 Oops

    add in missing code 3 pick 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 pick 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  5. 1 reword e92e34f Refactor existing code 2 pick 80601e8 Oops

    add in missing code 3 pick 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 pick 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  6. 1 reword e92e34f Refactor existing code 2 pick 80601e8 Oops

    add in missing code 3 edit 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 pick 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  7. 1 reword e92e34f Refactor existing code 2 pick 80601e8 Oops

    add in missing code 3 edit 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 squash 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  8. 1 reword e92e34f Refactor existing code 2 fixup 80601e8 Oops

    add in missing code 3 edit 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 squash 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  9. 1 reword e92e34f Refactor existing code 2 fixup 80601e8 Oops

    add in missing code 3 edit 8d91f76 Remove extra piece I left behind 4 pick 933bd58 Fix bug reported in #9895 5 squash 99302ef Clean up changes 6 pick 5cc3c5a Fix spelling mistake in documentation 7 8 # Rebase 0131d99..5cc3c5a onto 0131d99 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log 16 # x, exec = run command (the rest of the line) using shell
  10. 628c168 HEAD@{0}: rebase -i (finish): returning to refs/heads/your-branch 628c168 HEAD@{1}:

    rebase -i (start): checkout master 628c168 HEAD@{2}: reset: moving to 628c168 bc503a1 HEAD@{3}: rebase -i (finish): returning to refs/heads/your-branch bc503a1 HEAD@{4}: rebase -i (pick): Add Person model and migration 1ad2ff2 HEAD@{5}: rebase -i (pick): Improve README section on git reflog 026457d HEAD@{6}: rebase -i (start): checkout master 633f620 HEAD@{7}: rebase -i (finish): returning to refs/heads/your-branch 633f620 HEAD@{8}: rebase -i (pick): Improve README section on git reflog 19f41a7 HEAD@{9}: commit (amend): Add Person model and migration 50718b1 HEAD@{10}: rebase -i (edit): Add Person model and migration 026457d HEAD@{11}: rebase -i (reword): Update README with sections on rebase and c8c6000 HEAD@{12}: rebase -i (reword): Update README with sections on rebase and 628fbd2 HEAD@{13}: rebase -i (squash): Update README description section 455dab0 HEAD@{14}: rebase -i (fixup): # This is a combination of 2 commits. 4392779 HEAD@{15}: rebase -i (start): checkout master 628c168 HEAD@{16}: rebase -i (finish): returning to refs/heads/your-branch 628c168 HEAD@{17}: rebase -i (start): checkout master 628c168 HEAD@{18}: rebase -i (finish): returning to refs/heads/your-branch 628c168 HEAD@{19}: rebase -i (start): checkout master 628c168 HEAD@{20}: rebase: aborting 1f935f7 HEAD@{21}: rebase -i (edit): Add Person model and migration
  11. EILEEN M. UCHITELLE Programmer at Basecamp ! eileencodes.com " @eileencodes

    # @eileencodes Slides: speakerdeck.com/eileencodes