How to properly rebase in SourceTree?

SourceTree 1.6.4.0 on Windows 7.

Let’s say the following is my starting point:

  • Using Atlassian SourceTree, error during stash apply. Not sure what to do
  • Why did sourcetree delete my commit?
  • SourceTree - rebase - Errors During Merge
  • How to add dll files to Git Repository
  • Does Git delete empty folders?
  • .gitignore doesn't ignore files
  • enter image description here

     C <- master
    /
    - A - B <- topic
    

    I want to rebase topic onto master.
    My goal is to have:

      C - A - B
      ^       ^
    master  topic
    

    but I end up with:

    enter image description here

    I can then do

    git push origin topic -f
    

    and I get the intended result, but what is the proper way to do this in SourceTree?

  • Using “KexAlgorithms diffie-hellman-group1-sha1” did not resolve “no matching key exchange method found” error
  • How to make “git push” include tags within a branch?
  • Migrate or export Github wiki to Gitlab
  • Troubles with git and Gemfile.lock
  • Error: fatal loose object ### (stored in .git/objects/… is corrupt)
  • Git commit, then rebase from master, then making small changes to the original commit
  • 2 Solutions collect form web for “How to properly rebase in SourceTree?”

    Update: SourceTree 1.9.1

    You can enable force push in Tools/Options/Git/Enable Force Push. After it is enabled you can check “Force Push” check box in the “Push” dialog.

    Original answer

    You have to do a force push, because topic branch is already published and you are rewriting history. Commits A and B from origin/topic are removed if you rebase.

    You should make a merge if you don’t want to do a force push, specially if you have a team members already working on topic.

    You can’t do a force push with SourceTree for Windows yet (see answers at atlassian forums).
    You can vote for this feature here: https://jira.atlassian.com/browse/SRCTREEWIN-338

    UPDATE: SourceTree Version 2.2.4 (57) (for Mac)

    Go to SourceTree/Preferences/General and click ‘Allow force push’ towards the bottom.
    Then you can click Force Push in the push dialog.

    Git Baby is a git and github fan, let's start git clone.