Some people like git merge --squash
due to the reason as follows:
Squashing to a single commit gives you an opportunity to clean up messy WIP commits and provide a good rationale for the changes your are merging.
https://coderwall.com/p/qkrmjq/git-merge-squash
However, I think there is some downside which exceeds the merit of producing a clean history.
git merge --squash
produces a non-merge commit. Therefore, Git will not recognize that the commit you are merging from as the merge base. This leads to unwanted merge result when 1) change A to B on branch X, 2)git merge --squash
from branch X to branch Y, and 3) change B to A (revert) on branch X, and 4) merge X into Y.After step 4, on branch Y, the change from A to B is NOT reverted. Here, this is 3-way merge, so a diff from branch X to merge base and another diff from branch Y to merge base are compared. The former one includes no change, and the latter ones include change from A to B, so the merge result include the change from A to B.
Commit author is overridden, which discards the contribution.
git merge --squash
produces a new commit with the name who didgit merge --squash
. Of course, the commit content is from the original commits. This sounds like stealing the contribution. This became a problem in https://github.com/Microsoft/winfile/pull/42#issuecomment-380681627
What are the proper use cases of git merge --squash
?