git subtree push --squash does not squash

It is possible that this is an error in the documentation of the subtree command.

The manual in git states:

options for 'add', 'merge', 'pull' and 'push'
    --squash              merge subtree changes as a single commit

If you check the more extended documentation in the original subtree project you will notice that the --squash option is only explained for add and merge, as the functionality is described for the process of bringing content into your repository. Since pull is a modified form of merge, it is also implied that it can use --squash.

The push in the manual list what does not make sense. The git subtree push subcommand is a combination of git subtree split and git push. This means that --squash should be an option also supported by split, but split is not listed in the manual list. It is neither ever stated in the documentation that it can use --squash.

The --squash option is indeed accepted by split and push without error, but after experiment with it it seems it makes no difference, just as your example states. My take is that it is there by mistake and just ignored by the split and push commands.


This is now (Git 2.5, Q2 2015) confirmed in the official git subtree documentation.

See commit 6ccc71a by Danny Lin (danny0838), 07 May 2015.
(Merged by Junio C Hamano -- gitster -- in commit 6263f58, 22 May 2015)

contrib/subtree: there's no push --squash

The documentation says that --squash is for 'add', 'merge', 'pull' and 'push', while --squash actually doesn't change the behavior of 'push'.
Correct the documentation.

--squash:

This option is only valid for add, merge, and pull commands.


With Git 2.29 (Q4 2020), the documentation for subtree (in contrib/) is clearer.

See commit ce820cb, commit f99c0c9 (18 Aug 2020) by Danny Lin (danny0838).
(Merged by Junio C Hamano -- gitster -- in commit 8923a45, 24 Aug 2020)

contrib/subtree: document 'push' does not take '--squash'

Signed-off-by: Danny Lin

git subtree push does not support --squash, as previously illustrated in 6ccc71a9 ("contrib/subtree: there's no push --squash", 2015-05-07, Git v2.5.0-rc0 -- merge listed in batch #4)

The documentation no longer mentions push.