我只需要一份冲突文件列表。
还有什么比:
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 | cut -f 2 | sort -u
or:
git ls-files -u | awk '{print $4}' | sort | uniq
我想我可以为此设置一个方便的别名,但我想知道专业人士是如何做到的。我会用它来写shell循环,比如自动解决冲突等等。也许可以通过插入mergetool.cmd来替换这个循环?
当前回答
也许这已经添加到Git中,但尚未解析的文件在状态消息(Git状态)中列出,如下所示:
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: syssw/target/libs/makefile
#
注意,这是Unmerged paths部分。
其他回答
查尔斯·贝利的回答略有变化,提供了更多信息:
git diff --name-only --diff-filter=U | xargs git status
git status --short | grep "^UU "
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向导https://github.com/makelinux/git-wizard分别计算未解决的冲突更改(冲突)和未合并的文件。冲突必须手动或使用mergetool解决。解决的未合并的更改可以添加和提交通常与git rebase -continue。
假设你知道git根目录${GIT_ROOT}在哪里,你可以这样做,
cat ${GIT_ROOT}/.git/MERGE_MSG | sed '1,/Conflicts/d'