mark-hahn
mark-hahn

Reputation: 489

squash more then two commits in sourcetree?

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.

Upvotes: 16

Views: 9984

Answers (1)

VonC
VonC

Reputation: 1325337

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.

Upvotes: 17

Related Questions