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

Oopsy - Getting out of (almost) anything with Git

Oopsy - Getting out of (almost) anything with Git

One of the big advantages of version control is knowing you have a safety net in case anything goes awry. In this workshop, we'll explore common predicaments and discuss how to use the best tool for the job to get out of different those tight spots. While the material we'll cover can help the beginner and the seasoned professional alike, attendees should have a basic working knowledge of Git and be comfortable on the command line.

Allen Smith

April 05, 2016
Tweet

More Decks by Allen Smith

Other Decks in Technology

Transcript

  1. " A B C D E " A B’ C’

    D’ E’ O/MASTER MASTER
  2. " A O/MASTER " A B C D E MASTER

    B’ C’ D’ E’
  3. " A " A B C D E O/MASTER MASTER

    B’ C’ D’ E’ FEATURE F
  4. DON’T REWRITE ANYTHING THAT IS PUBLIC. UNLESS YOU HAVE… ‣

    EXHAUSTED ALL OTHER OPTIONS ‣ DISCUSSED IT WITH YOUR COLLABORATORS ‣ CREATED A PLAN FOR UPDATING
  5. $ git checkout -- <file> " A B C D

    FEATURE $ file.txt HEAD
  6. $ git reset --hard <tree-ish> " A B C D

    FEATURE $ file.txt HEAD $ file.js $ file.css E F
  7. $ git reset --hard <tree-ish> " A B C D

    FEATURE $ file.txt HEAD $ file.js $ file.css E F
  8. $ git branch <name> " A B C D MASTER

    HEAD E F ORIGIN/MASTER
  9. $ git branch <name> " A B C D MASTER

    HEAD E F FEATURE ORIGIN/MASTER
  10. $ git reset --hard origin/master " A B C D

    MASTER HEAD E F FEATURE ORIGIN/MASTER
  11. $ git reset --hard origin/master " A B C D

    MASTER HEAD E F FEATURE ORIGIN/MASTER
  12. $ git rebase master " A B E F FEATURE

    HEAD C D MASTER C’ D’
  13. $ git commit --fixup <commit> " A B C D

    FEATURE HEAD E F MASTER
  14. >

  15. A B C G K L D E F H

    I J WHAT HAPPENED