squash more then two commits in sourcetree?

mark-hahn picture mark-hahn · Aug 3, 2014 · Viewed 8.3k times · Source

I have a large number of commits, about 20, that I've done since my last push to origin/master. I have never had more than one branch, master, and all commits were done on master. How can I squash all 20 commits into one commit, preferably using sourcetree? I want to do this so I can just push one commit to origin/master.

In sourcetree I have figured out to use the interactive rebase command in the repository menu. It brings up the exact list of commits I want to squash. I tried hitting the squash button repeatedly until it shows one commit containing all of them. But when I hit OK I end up with only the two most recent commits squashed. So even though the dialog seems to show it can squash multiple in practice I can't get it to work.

Answer

VonC picture VonC · Aug 3, 2014

Easier solution (than a rebase):

Select the "origin/master" commit in the log entry, click on "Reset <branch> to this commit".

http://i.imgur.com/nWDzb6k.png

Use the default mixed mode.

http://i.imgur.com/bTaS5KD.jpg

Then add and commit: all your changes will be registered again in one new commit, that you will be able to push.

See git reset Demystified for more.