![]() ![]() ![]() The most obvious one is for a local branch where WIP commits are made, before pushing them somewhere other devs can see. So it might not be useful in all cases, but there definitely are cases where it's perfectly fine to use. If all the commits on the branch are by the same author, then the second problem doesn't exist either. Or if you rebase branch Y on X after the merge, then future merges from Y will have the right merge-base. You're not going to do any future merges from Y anyway. because Y is a short-lived feature branch and the feature is merged to X now) then it's irrelevant that a future merge from Y has the "wrong" merge-base. If you don't plan to use the Y branch again after the merge (e.g. If the project has a policy of not allowing merge commits on its master branch anyway, then the fact a non-merge commit is created is not a problem (it's exactly what you'd want anyway). What are the proper use cases of git merge -squash? This sounds like stealing the contribution. Of course, the commit content is from the original commits. git merge -squash produces a new commit with the name who did git merge -squash. 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.Ĭommit author is overridden, which discards the contribution. 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. 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.Īfter step 4, on branch Y, the change from A to B is NOT reverted. Therefore, Git will not recognize that the commit you are merging from as the merge base. ![]() Git merge -squash produces a non-merge commit. However, I think there is some downside which exceeds the merit of producing a clean history. 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. Some people like git merge -squash due to the reason as follows: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |