Mark Allison Mark Allison - 1 year ago 80
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download