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,043
  • 26
  • 90
  • 140
  • 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,002
  • 11
  • 22
0

Stash all your changes, then:

 git branch develop
 git reset --hard HEAD~4
Philippe
  • 21,230
  • 5
  • 41
  • 62