Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to squash merge multiple commits from branch to master in a single commit using SmartGIT?

I have a branch called work_in_progress which is used to debug and test code with many small commits. All of them have redundant commit messages. When I'm finished I want to merge squash to master branch. Usually this is one single command when merging using the --squash parameter.

But how do I do it with SmartGIT?

The documentation here How to perform squash merges seems to be wrong because there is no option "Branch consisting of selected commit and its ancestors".

The documentation here How to perform normal merges and squash merges simply does not work. I have tried it and I still see all the small commits in the log. I can delete the work_in_progress branch afterwards, all fine, but I want a single commit with a single commit message in the history of the master branch.


Edit: Here is a screenshot from my commit dialog. I guess I'm missing the "Simple commit" option?! Maybe I don't understand the instructions^^ enter image description here


Edit 2: Here is a screenshot of the Log. The second commit from the top was done using SmartGIT. You can see that all the intermediate commits (including the messages) are visible in the history. The branch was called XYZ_work_in_progress. The last (top most) commit was done using "git merge --squash ABC_work_in_progress" but all the commits are swallowed so it's a clean history. All the work from the branch is accumulated into a single commit with a single message :-) enter image description here

like image 743
FrozenTarzan Avatar asked Dec 04 '25 11:12

FrozenTarzan


1 Answers

Here's the typical situation: Things developed on your feature branch, meanwhile the world kept turning and more stuff happened on the common master branch.

before: rebase feature branch (recommended)

  1. feature and master branch, all pulled and pushed. No pending commits.
  2. You should have checked out your feature branch and be on its tip (head-revision), the yellow-green label tells you. (Having yellow and green next to each other assures you that there is no push or pull pending.)

enter image description here

4) right-click on the master tip (line1) pick Rebase HEAD to... (certainly not Rebase to HEAD... ➝ trouble, that won't become so obvious for several steps...). Press the Button in the dialog to confirm.

5) You got the feature commits played on top. As hollow orange circles, since things are not yet committed.

6) right-click on feature branch, say Push to.... Pick (o)Tracked or matching branch and —important— [x]Force Pushing (since you are “changing history” of your feature branch...)

History is now looking clean, your commits being in line, aka fast-forwardable:

enter image description here

Squash commit

  1. Switch to (check out) Master tree. Right-click on feature branch, say Merge.... In the options dialog, you have to pick Merge to Working Tree (otherwise the commit happens without you being able to pick any options, i.e. squash).

enter image description here

  1. you may or may not have to go through resolving and then continue.

  2. Finally, say commit. Pick (o) Simple commit (one parent, "squash")

enter image description here

...and there she is:

enter image description here

like image 175
Frank Nocke Avatar answered Dec 07 '25 04:12

Frank Nocke