Move the most recent commit(s) to a new branch with Git
Asked 07 September, 2021
Viewed 2.9K times
  • 62
Votes

I'd like to move the last several commits I've committed to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu is not strong enough yet, any help?

I.e. How can I go from this

master A - B - C - D - E

to this?

newbranch     C - D - E
             /
master A - B 

15 Answer