When I do a git merge
I would like that only the files that can be fast-forwarded (i.e. the files that have changed only on one of the branches being merged since the last common revision) are automerged, while all the other files (that have changed on both branches, even if on different lines) are marked as conflicts. I have looked around but it seems that there is not a "simple" way (e.g. an option to pass to git merge
) to do that. Here there is a similar question, but not quite this one. Here there is a very similar question, but it is 4 years old and it has no conclusive answer.
Asked
Active
Viewed 2,835 times
5

Community
- 1
- 1

UndefinedBehavior
- 836
- 1
- 11
- 20
-
1For what it's worth, "fast forward" is not the right phrase here as it refers to branch label operations, which are based on the commit graph. The content of any given commit is not controlled by the graph (although certain degenerate graph cases do limit the possibilities for content-changes). – torek Oct 30 '15 at 08:15
2 Answers
1
As far as I know it's not possible to do this without using some sort of script (shouldn't be too difficult). I looked for a similar solution a couple months back and I simply ended up disabling the fast-forwarded merge. I think they mention how in some of the questions you added:
git merge --no-ff

Jelle
- 576
- 2
- 10
1
Put * -merge
in .git/info/attributes
of the repository where you're performing the merge. This will prevent any auto-merging, introducing merge conflicts instead.
Note that .git/info/attributes
has the highest precedence of all .gitattribute
files, so none of those would cancel it out.

dragonroot
- 5,653
- 3
- 38
- 63