.gitattributes中的合并策略无效 [英] merge strategy in .gitattributes not working
问题描述
我希望git永远不会在此文件上发生冲突:
test / file.txt
合并时。
我在.gitattributes
test / file.txt merge = theirs
中尝试了以下内容,但我需要定义他们的
合并策略。我在网上看到我可以通过执行以下命令来定义我们的
策略:
git config --global merge.theirs.driver true
将驱动程序设置为true(bash true),它将保留本地文件而不是新文件。
我想做相反的。我如何定义他们的
驱动程序来获取新副本,并在合并时丢弃本地副本(在git pull之后)?
如何定义他们的驱动程序以获取新副本并放弃合并时的本地副本(在 git之后)拉
)?
正如我在如何让git始终选择我的本地版本来处理特定文件上的冲突合并?,则需要调用脚本:
git config merge.keepTheir.name合并时始终保留它们
git config merge.keepTheir.driverkeepTheir.sh%O%A% B
使用 keepTheir.sh
您的 PATH
中的任何位置)
cp -f $ 3 $ 2
exit 0
git config merge.keepTheir.drivercp -f%B%A
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
but I need to define the theirs
merge strategy. I saw online that I can define the ours
strategy by executing this:
git config --global merge.theirs.driver true
which sets the driver to true (bash true) which will keep the local file instead of the new one.
I want to do the opposite. How can I define the theirs
driver to get the new copy and discard the local one when merging (after a git pull)?
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"
这篇关于.gitattributes中的合并策略无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!