Cannot get how to perform squash rebase for the current branch. The console command would be
git rebase -i HEAD~2
and then squash as usually. But how to do the same in TGit?
Script to initialize the case
git init .
git add 1
git commit -m "1"
git add 2
git commit -m "2"
git add 3
git commit -m "3"
As a result after squashing we would have 1 commit with 3 files.
Don't do any of the previous! Just combine 2 commits using the interface. Remember not do combine commits already on the shared repo. See:
This works for me using TortoiseGit 1.7.12:
Show logfrom the context menu.
Rebase master onto this...from the context menu.
Force Rebasecheckbox and then right-click on the commit to choose between
Squash, etc., or tick the
Squash ALLcheckbox in your case.
Start Rebasebutton, which on success turns into a
Commitbutton, and then into a
Donebutton. 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 (which is apparently via similar to GitHub).
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
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.
One way is: Go to log dialog and select "rebase onto *" and then check the "Force" checkbox and mark the commits for "squash" (e.g. by typing 'q').