我只需要一份冲突文件列表。

还有什么比:

git ls-files -u  | cut -f 2 | sort -u

or:

git ls-files -u  | awk '{print $4}' | sort | uniq

我想我可以为此设置一个方便的别名,但我想知道专业人士是如何做到的。我会用它来写shell循环,比如自动解决冲突等等。也许可以通过插入mergetool.cmd来替换这个循环?


当前回答

你可以在命令行上点击git ls-files -u,它会列出有冲突的文件

其他回答

git status --short | grep "^UU "

对我来说,公认的答案并不管用。为了防止捕获

警告:[]中的LF将被CRLF取代。 该文件在您的工作目录中有其原始的行结束符

在Powershell中我使用了这种方法:

git ls-files -u| ForEach{($_.Split("`t"))|Select-Object -Last 1}| get-unique

Git diff——检查

将显示包含冲突标记(包括行号)的文件列表。

例如:

> git diff --check
index-localhost.html:85: leftover conflict marker
index-localhost.html:87: leftover conflict marker
index-localhost.html:89: leftover conflict marker
index.html:85: leftover conflict marker
index.html:87: leftover conflict marker
index.html:89: leftover conflict marker

来源:https://ardalis.com/detect-git-conflict-markers

假设你知道git根目录${GIT_ROOT}在哪里,你可以这样做,

 cat ${GIT_ROOT}/.git/MERGE_MSG | sed '1,/Conflicts/d'

也许这已经添加到Git中,但尚未解析的文件在状态消息(Git状态)中列出,如下所示:

#
# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   both modified:      syssw/target/libs/makefile
#

注意,这是Unmerged paths部分。