From this:
master A - B - C - D - E
Move C - D - E
to a new branch:
newbranch C - D - E
/
master A - B
This can be easily done by branching and rolling back.
git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch
git push origin newbranch
But do make sure how many commits to go back. Alternatively, you can instead of HEAD~3, simply provide the hash of the commit you want to "revert back to" on the master (/current) branch, e.g:
git reset --hard a1b2c3d4
And remove commits from master:
git checkout master
git reset --hard HEAD~3
git push --force
Just rewriting history.
Extracted from stackoverflow question Move the most recent commit(s) to a new branch with Git