merge strategy in .gitattributes not working

后端 未结 1 1293
我寻月下人不归
我寻月下人不归 2021-01-16 10:47

I want git to never have a conflict on this file:
test/file.txt
when merging. I tried the following in .gitattributes test/file.txt merge=theirs

1条回答
  •  抹茶落季
    2021-01-16 11:13

    How can I define the theirs driver to get the new copy and discard the local one when merging (after a git pull)?

    As I mentioned in "How do I tell git to always select my local version for conflicted merges on a specific file?", you would need to call a script like:

    git config merge.keepTheir.name "always keep their during merge"
    git config merge.keepTheir.driver "keepTheir.sh %O %A %B"
    

    With keepTheir.sh (put anywhere in your PATH)

    cp -f $3 $2
    exit 0
    

    Or, as jthill suggests below in the comments, directly:

    git config merge.keepTheir.driver "cp -f %B %A"
    

    0 讨论(0)
提交回复
热议问题