Mark Allison Mark Allison - 6 months ago 23
Git Question

How to branch from n-4 commits, and set n-4 as master?

I should have created a branch called

n-4 commits ago, can I go back and set n-4 to be
and create a new branch from that point which includes the last n-4 commits?

I'm using GitExtensions on Windows but happy to do from commandline if easier.


You can do it using following commands:

git checkout -b develop HEAD
git branch -f master HEAD~4

First one creates a new branch develop. Next just reset the branch master