通过工作目录并通过xargs命令发送输出:
grep -lr'<<<<<<<< ;<<'。 | xargs git checkout --ours
或
grep -lr'<<<<<<<<<
这是如何工作的: grep 将搜索当前目录中的每个文件(。)和子目录( -r )标志)查找冲突标记(字符串'<<<<<<<'< / p>
< code& / code>或 - files-with-matches 标志会导致grep仅输出找到该字符串的文件名。扫描在首次匹配后停止,因此每个匹配的文件只输出一次。
匹配的文件名称到,这是一个将管道输入流分离的实用程序转化为 git checkout --ours 或 - 它们的
更多。
由于每次在命令行输入它都会非常不方便,如果您发现自己使用它很多,创建一个:是通常的。
这种方法应该至少可以通过Git版本
Is there a way to resolve conflict for all files using checkout --ours and --theirs? I know that you can do it for individual files but couldn't find a way to do it for all.
Just grep through the working directory and send the output through the xargs command:
grep -lr '<<<<<<<' . | xargs git checkout --ours
or
grep -lr '<<<<<<<' . | xargs git checkout --theirs
How this works: grep will search through every file in the current directory (the .) and subdirectories recursively (the -r flag) looking for conflict markers (the string '<<<<<<<')
the -l or --files-with-matches flag causes grep to output only the filename where the string was found. Scanning stops after first match, so each matched file is only output once.
The matched file names are then piped to xargs, a utility that breaks up the piped input stream into individual arguments for git checkout --ours or --theirs
More at this link.
Since it would be very inconvenient to have to type this every time at the command line, if you do find yourself using it a lot, it might not be a bad idea to create an alias for your shell of choice: Bash is the usual one.
This method should work through at least Git versions 2.4.x
这篇关于使用--ours / - 他们的所有文件解决冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!