Antoniossss Antoniossss - 26 days ago 4
Git Question

How to rebase specified commit to different branch using SourceTree?

I have the following situation:

SourceTree Git log output

How can I

last commit from staging (removed ProxyFinder...) onto
using SourceTree?

One way would be to merge
and then reset
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:

  1. Double-click warning-fixes to check it out.
  2. Right-click on staging.
  3. Click Merge staging into current branch.
  4. Double-click staging to check it out.
  5. Right-click the previous commit, where origin/staging currently is.
  6. Click 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 since there is only one commit, it will have exactly the same effect as a merge.