Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
767 views
in Technique[技术] by (71.8m points)

version control - How to get 3-way merge in GIT on non-conflict merges?

How to disable auto-merging in GIT?

The purpose is to have the same behaviour as for conflict merges resolution in automatic merges during invocation of command chain:

$ git fetch
$ git merge some_branch
$ git mergetool

The last command leads us to 3-way merge of files in case of merge conflicts. I would like to have an easy way of performing the same 3-way merge on files without conflict merges.

I couldn't find any solution on the internet, is there any?

I've some workarounds in mind, but it would prefer to avoid it.

Thanks in advance,

Aleks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For changes that were made only on one side or the other, you can prevent automatic merges by unsetting the merge attribute (see gitattributes under “Performing a three-way merge”). A merge made for a pathname that lacks the merge attribute (or has it set to “binary”) will leave the version from the current branch in the working tree and leave the index entry for the pathname in a conflicted state.

If you want to encourage everyone to work this way, you can put in into a .gitattributes file and commit it. If you only want to do this for yourself, you can put it in an uncommited .gitattributes files or put it in your repository's $GIT_DIR/info/attributes file (which you could add/remove/rename at will to enable/disable the attribute).

#    repository/.git/info/attributes
# OR
#    .gitattributes
* -merge

If an identical change is made on both sides, even this configuration will not cause a conflict.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...