.gitattributes 中的合并策略不起作用
merge strategy in .gitattributes not working
我希望 git 永远不会与此文件发生冲突:
test/file.txt
合并的时候。
我在 .gitattributes 中尝试了以下内容
test/file.txt 合并=他们的
但我需要定义 theirs
合并策略。我在网上看到我可以通过执行以下命令来定义 ours
策略:
git config --global merge.theirs.driver true
它将驱动程序设置为 true (bash true),这将保留本地文件而不是新文件。
我想做相反的事情。我如何定义 theirs
驱动程序以在合并时获取新副本并丢弃本地副本(在 git 拉取之后)?
How can I define the theirs driver to get the new copy and discard the local one when merging (after a git pull
)?
正如我在“How do I tell git to always select my local version for conflicted merges on a specific file?”中提到的,您需要调用如下脚本:
git config merge.keepTheir.name "always keep their during merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"
使用 keepTheir.sh
(放在 PATH
中的任意位置)
cp -f
exit 0
或者,如jthill suggests below ,直接:
git config merge.keepTheir.driver "cp -f %B %A"
此外,如 Tal Jacob - Sir Jacques in 所述:
after you have configured the 'keepTheir
' driver in the config
file, you should navigate to your .gitattributes
file and add the line:
test/file.txt merge=keepTheir
我希望 git 永远不会与此文件发生冲突:
test/file.txt
合并的时候。
我在 .gitattributes 中尝试了以下内容
test/file.txt 合并=他们的
但我需要定义 theirs
合并策略。我在网上看到我可以通过执行以下命令来定义 ours
策略:
git config --global merge.theirs.driver true
它将驱动程序设置为 true (bash true),这将保留本地文件而不是新文件。
我想做相反的事情。我如何定义 theirs
驱动程序以在合并时获取新副本并丢弃本地副本(在 git 拉取之后)?
How can I define the theirs driver to get the new copy and discard the local one when merging (after a
git pull
)?
正如我在“How do I tell git to always select my local version for conflicted merges on a specific file?”中提到的,您需要调用如下脚本:
git config merge.keepTheir.name "always keep their during merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"
使用 keepTheir.sh
(放在 PATH
中的任意位置)
cp -f
exit 0
或者,如jthill suggests below
git config merge.keepTheir.driver "cp -f %B %A"
此外,如 Tal Jacob - Sir Jacques in
after you have configured the '
keepTheir
' driver in theconfig
file, you should navigate to your.gitattributes
file and add the line:test/file.txt merge=keepTheir