1

I should have created a branch called develop n-4 commits ago, can I go back and set n-4 to be master 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.

Mark Allison
  • 6,838
  • 33
  • 102
  • 151
  • 5
    Possible duplicate of [Branch from a previous commit using git](http://stackoverflow.com/questions/2816715/branch-from-a-previous-commit-using-git) – quadroid Aug 15 '16 at 10:48
  • No because I want to include the last n-4 commits in my branch and put master back to n-4. – Mark Allison Aug 15 '16 at 10:55

2 Answers2

2

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

Rishit Sanmukhani
  • 2,159
  • 16
  • 26
0

Stash all your changes, then:

 git branch develop
 git reset --hard HEAD~4
Philippe
  • 28,207
  • 6
  • 54
  • 78