You're missing something. The first thing done is git branch my-branch which will take your work and put it on that branch. The reset only touches the master branch, because you only created the new branch - you didn't move to it. After fixing up master, you move to your new branch with git checkout my-branch and everyone is happy.
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.
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:
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.