How to perform rebase (squash) using tortoisegit

You can combine two adjacent commits using the GUI as follows. Remember not do combine commits already on the shared repository. See: Right click 2 commits


This works for me using TortoiseGit 1.7.12:

  1. Right-click on the working directory where you want to do an interactive rebase and choose TortoiseGit -> Show log from the context menu.
  2. In the appearing "Log Messages" dialog, right-click on the most recent commit that you would not like to rebase anymore and choose Rebase master onto this... from the context menu.
  3. In the appearing "Rebase" dialog, tick the Force Rebase checkbox and then right-click on the commit to choose between Pick, Squash, etc., or tick the Squash ALL checkbox in your case.
  4. Press the Start Rebase button, which on success turns into a Commit button, and then into a Done button. Press all of them.

Note that in your example script you would squash / fixup to the root commit, which is a special case and does not work as described above because the root commit has no parent that you could select in step 2.


Here's what I did using Tortoise Git & storing the repo on Assembla (a service which competes with GitLab, BitBucket, etc).

I decided I wanted to effectively delete my entire commit history, and start the repo over from scratch. I could have deleted the local git folder and the corresponding repo in Assembla, and then recreated it, but thought it was better to figure out how to do this the “right way”.

So, here’s how I achieved it:

  1. Using Tortoise Git, display the repo’s log. Highlight all the commits, right click on them, and select “combine into one commit”.

  2. In the dialog that pops up, delete the commit comment (which becomes a combination of all the prior comments), and replace it with a single comment e.g. REBASE. Then initiate the commit. The local repo will then be effectively started from scratch (with all the files still added to it of course) without having to delete and recreate it.

  3. Unfortunately, you can’t just push it to Assembla. It will reject this, insisting that your “head” is behind the remote branch. So, to solve that first go to the “Settings” page for the repo in Assembla. Enable “Allow –force push”.

  4. Now perform a “forced push”. I don’t know if Tortoise Git has a gui option for this, but it is easy to do via the command prompt:

    cd [your repo folder] git push -f origin

Done!

UPDATE:

To "force push" with TortoiseGit, in the push dialog there are checkboxes to force "known changes" and "unknown changes". I'm not sure what the difference is, but they both result in using the git --force switch. Try "known changes" to begin with.


  • Go to Show Log, then make a tag at your current commit (e.g. "tmp").
  • Reset hard to the first commit back in history you don't want to change.
  • Toggle All Branches at the bottom of the log, if you don't see all commits.
  • Then select all newer commits and make a right click on them: Cherry Pick selected commits...
  • Now you are in interactive rebase mode. There you can do what is common for interactive rebase.