How do I tell git to always select my local version for conflicted merges on a specific file?

后端 未结 3 1919
一向
一向 2020-11-21 23:58

Say I\'m collaborating with someone via a git repository, and there is a particular file that I never want to accept any external changes to.

Is there any way for me

3条回答
  •  别跟我提以往
    2020-11-22 00:27

    As @ciro-santilli has commented, the simple way to do it to use .gitattributes with settings it:

    path/to/file merge=ours
    

    and enable this strategy with:

    git config --global merge.ours.driver true
    

    (I am adding this as an answer to make it more visible but making it a Community Wiki to not try to get above user's credits for myself. Please upvote his comment under the Q here to give him kudos!)

提交回复
热议问题