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

Undo, Redo, Change History with Git

Undo, Redo, Change History with Git

Undo, Redo and Change History with Git

Joshua Wehner

January 28, 2015
Tweet

More Decks by Joshua Wehner

Other Decks in Programming

Transcript

  1. Regrets, I've Had a Few • Ooooops • That's mostly

    rubbish • git reset <last good sha>
  2. Throw It All Away • It's all rubbish • I

    regret everything • git reset --hard <last good sha>
  3. Wait, On Second Thought • Throw It All Away •

    Could I maybe get that back? • git reflog git reset --hard <sha>
  4. Well, That Wasn't So Bad • Most of that is

    trash • But that one? That one is good. • Gimme. • git cherry-pick <good one>
  5. Put That Thing Over There • I should have made

    this branch earlier • Those commits should not be on master • git rebase master
  6. Well, Then Again • Throw It All Some of It

    Away • I regret that one thing • Some of the rest of it was okay • git rebase -i <public sha>
  7. I Was Wrong Before • I thought I was wrong

    • But I wasn't • git commit --fixup <sha> git rebase -i --autosquash
  8. Forget I Said That • Stop tracking this file •

    I mean it • git rm --cached .gitignore git clean -f (also -x maybe?)