Use 3-way merge for squashing commits
A high number of squashes fail because some lines in the target branch changed in another commit. However, this failure doesn't happen if you attempt to squash a branch and merge it in this way:
- git checkout my-branch
- git rebase -i HEAD~N (where N is some number of commits)
- git checkout master
- git merge my-branch
The fourth step does a 3-way merge by default. From https://git-scm.com/docs/merge-strategies#_merge_strategies under recursive
:
This can only resolve two heads using a 3-way merge algorithm...This is the default merge strategy when pulling or merging one branch.
To emulate this behavior, we add --3way
to the parameters when we attempt to apply the patch onto the
target branch.
Part of https://gitlab.com/gitlab-org/gitlab-ee/issues/10661
Edited by GitLab Release Tools Bot