I have the following situation:
How can I rebase
last commit from staging (removed ProxyFinder...) onto warning-fixes
using SourceTree?
One way would be to merge staging
into warning-fixes
and then reset staging
to previous commit, but that sounds like nasty workaround.
The best way to do it is as mentioned in @ElpieKay's comment, and at the end of your question: merge staging
into warning-fixes
and then reset staging
to previous commit.
To do it from the command line, do:
git checkout warning-fixes
git merge staging
git checkout staging
git reset --hard HEAD^
In SourceTree:
warning-fixes
to check it out.staging
.Merge staging into current branch
.staging
to check it out.origin/staging
currently is.Reset current branch to this commit
.The reason you don't want to use rebase
is that it doesn't just move the commits, but it also moves the branch pointer. In this case, attempting to rebase staging
onto warning-fixes
would have no effect, since the commit at the tip of staging
already has the same parent as the tip of warning-fixes
.
The only real alternative is to use cherry-pick
, but this will (by default) create a duplicate commit with a new committer date. (And it becomes a pain if you have more than one commit to move.)