Sometimes I squash a bunch of commits together. Usually my commands follow this pattern:
git reset --hard HEAD~4
git merge --squash HEAD@{1}
git commit
Today, though, at step 2, I got distracted by something (squirrel? Slack? Facebook?) and I forgot to end the git merge --squash
command with HEAD@{1}
. Yet it magically did what I wanted.
I can't find any documentation that omitting the target of the merge will default to HEAD@{1}
, but it was nice that it worked out.
Is there documentation on this somewhere?
I see the following from git help merge
, but it doesn't seem to answer the question:
--squash, --no-squash
Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move the HEAD, or record $GIT_DIR/MERGE_HEAD (to cause the next git commit command to create a merge commit). This
allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).
With --no-squash perform the merge and commit the result. This option can be used to override --squash.
With --squash, --commit is not allowed, and will fail.