If you hadn't made any commit yet, only (1: branch) and (3: checkout) would be enough.
Or, in one command: git checkout -b newBranch.
As mentioned in the git reset man page:
1. $ git branch topic/wip
2. $ git reset --soft HEAD~3
(or --hard to remove unindexed files)
2. $ git checkout topic/wip
- You have made some commits, but realize they were premature to be in the "
master" branch. You want to continue polishing them in a topic branch, so create "topic/wip" branch off of the currentHEAD. - Rewind the
masterbranch to get rid of those three commits. - Switch to "
topic/wip" branch and keep working.