Possible Duplicate:
git: how to move some commits to new branch
I have git master branch on which I have done many commits. I now do realize that the last four commits should have been on a separate branch, What is the easiest way to achieve this?
Possible Duplicate:
git: how to move some commits to new branch
I have git master branch on which I have done many commits. I now do realize that the last four commits should have been on a separate branch, What is the easiest way to achieve this?
assuming you are on master:
git checkout -b new_branch
git push . +head~4:master
This will leave you on your new branch and will not have any impact on your working directory. I assume this is where you would want to be after. This can have impact if you have editors open such as VisualStudio which are notorious for holding locks on files and getting in the way of checkouts.
This way you can leave all editors open and still get what you want done: - make the current commit the head of a specific branch - make master point to where it should have been - leave the working directory alone so you don't have to close any editors, etc.
Hope this helps.