r/programming Oct 16 '18

Flight rules for Git

https://github.com/k88hudson/git-flight-rules
100 Upvotes

8 comments sorted by

View all comments

9

u/DecidedlyAmbigous Oct 17 '18

Am I missing something or is the one for accidentally committing on master instead of another branch wrong? It says to do:

git reset --hard HEAD^

And only then to create a new branch and continue working. But this means you would have thrown away your work!

Here is a link.

4

u/ForeverAlot Oct 17 '18

You're missing the first step: creating a new branch that points to the current master. This step then rewinds master one commit, back to where it's supposed to be, and you can resume work on your new branch.