Sometimes, I find myself in a series of commits which should have been done in a separate branch:
A - B - C - D - E - F (master)
^- first commit that should not be in master
Here's what it should look like:
A - B - C (master)
\
D - E - F (branch)
And here's what to be done:
(master)$ git checkout -b branch
(branch)$ git checkout master
(master)$ git reset --hard C
First, create the branch off the last commit, then go back to master and reset it to ref C
. Done.