I recently started using git commit --fixup
and --squash
options. I use --fixup
option for, ehm, fixups. When I commit with --fixup
option, commit message is constructed automatically. For example, when I commit
$ git commit -m '[#123] Lorem ipsum dolor sit amet'
then I do some minor editing
$ git add .
$ git commit --fixup :/123
will autogenerate commit message fixup! [#123] Lorem isum dolor sit amet
. However, when I use --squash
option instead, such as
$ git add .
$ git commit --squash :/123
git will run text editor and ask me to write the commit message, but at the same time, it will generate and insert in the editor the default commit message squash! [#123] Lorem ipsum dolor sit amet
.
My question is: What is the best practice for writing --squash
commit messages? With --fixup
option, there is no confusion, because git will autogenerate the message and give me no choice of editing it. But with --squash
option, git on autogenerates the message on one hand, but gives me the option of editing it on the other hand. The conundrum is, if I always just accept the autogenerated message squash! [#123] ...
, what is the purpose of git giving me the opportunity to edit it, and what is the purpose of having --squash
option in addition to --fixup
if it does the same thing? I am afraid that if I edit the message in a wrong way, git will no longer recognize the commit as intended to be autosquashed to the original [#123]
commit.