How do I prevent an automerge using Git?

前端 未结 5 1466
孤独总比滥情好
孤独总比滥情好 2020-11-28 20:47

I am trying to merge a local branch into the master branch without having Git to do an automerge. I would like to “hand pick” what I would like to be merged into master.

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 21:34

    I can see you may wish to do this if you do not trust auto-merge, because two edits in different places in a file (which are done on different branches) may not cause auto-merge to raise a conflict but may not actually work together.

    You may want to look at using a custom merge driver. This page describes how to go about it.

    Git - how to force merge conflict and manual merge on selected file

    An alternative would be to find the files that differ between the branches first, before performing the merge, then checkout the file into the appropriate branch to ensure you get a clean merge and functional code that contains either one or the other of the two edits.

    git diff --name-only   
    git checkout  -- 
    

提交回复
热议问题