Why doesn't `git merge <branch> --squash` make a commit?

What's the rationale behind this?

The draft merge commit message will contain all your squashed messages from the other branch. Something like this:

Squashed commit of the following:

commit 2fb77b77f813501ae2c8159e7bf751c216572a57
Author: Your Name <[email protected]>
Date:   Tue May 22 22:47:50 2018 +0200

    Drop baz

commit 894f1ef07af29d25c4716dce9db4402032f854d4
Author: Your Name <[email protected]>
Date:   Tue May 22 22:47:39 2018 +0200

    Fix bar

commit 7f60998ab1949e9e8db9229f9ef9e7c0333cd04f
Author: Your Name <[email protected]>
Date:   Tue May 22 22:47:19 2018 +0200

    Add foo

Usually, you will want to customize that message before committing.


If you are happy with the default message you could do:

git merge <branch> --squash && git commit --no-edit

This sort of why question really has to be sent to whoever wrote the command in the first place; only they really know.

The underlying implementation is lazy: it goes through the same code path as regular merge but skips writing the file MERGE_HEAD, and then exits early to avoid going through the code that would make a merge commit.

If you use the --no-commit option, the code goes through nearly the same path. In fact, the control variable for this is option_commit, and setting --squash clears option_commit as if you ran with --no-commit.

If --squash didn't clear option_commit, it looks like the existing path would complain that the automerge failed. So it may simply be laziness.