+2

New commit & squash command

Pierre Goiffon 1 year ago updated by Thomas Singer 5 months ago 9

From time to time I find that one of my modifications would better fit in an unpushed commit that is not the last one. For example I've git commit A, B, C, I have modifications in my working tree, and I find that one hunk should fit in commit B.


In such situation, I :

* commit the concerned hunks

* in the commit dialog select the commit B message

* commit

* in the log view, launch an interactive rebase

* click on the "auto squash" button

* validate


Having in the commit dialog the option to directly squash staged hunks in a defined commit would be fine !

So in this example, stage the hunks, open the commit dialog, select the squash option, selection commit B, validate.

+1

Please use "Use Message for Commit" and then the interactive rebase. It highlights equally named commits and offers auto-squash commands.

+1

It defaults to the newest commit and so far I always choose the oldest commit, unless I forget to change this!  Please add a config item to set the default, either "newest commit" or "oldest commit".

I totally agree ! Same for me.

Try what in it?  I always run latest preview.  I do not find anything to set a default.

Did you see the 3 options of the "Auto-Squash"-button in the Interactive Rebase dialog?

Sorry, I understand now that we are talking about 2 different squash features because the context of this RFE is rebase interactive.  The SG RI feature works well for me as is because the default chooses the older commit info.


I didn't mean to hijack the topic - to summarize, I was referring to the "Authorship" field on the Squash Commits dialog.  Authorship items are sorted descending/newest first, and the first one is selected by default.  I sometimes forget to change it to the older one!  I want either it to select the oldest by default or have a config option allowing user to choose which it selects by default.

Hello,

As stated in the description (apart from the commits with same message that are colored in the interactive rebase dialog, it wasn't the case at this time and it's a feature I love 8) ), this is what I do now. But doing this 2 or 3 times in a row is painful... Having a mean to do it in one click would be a very nice feature for me !

For me it often happens that I need to amend different commits in a row. I now use "Use Message for Commit" and commit my changes (for multiple commits). If I have done all my commits, I use Interactive Rebase with one of the Auto-Squash options. I can't imagine a simpler work-flow. One always need to select the files to commit, select the commit's message to use.


Adding this to the Commit would make the already difficult Commit even more difficult to catch all border cases. So, for example, it is unexpected to get a conflict when committing, but this might happen with your suggestion 2 times - for the necessary rebase after the commit and for the auto-stash/apply/stash if there are local changes.