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

还有什么比:

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

or:

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

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


当前回答

使用git diff,带name-only只显示名称,diff-filter=U只包括'Unmerged'文件(可选地,相对于当前工作目录显示路径)。

git diff --name-only --diff-filter=U --relative

其他回答

我一直只使用git状态。

可以在最后添加awk来获得文件名吗

git status -s | grep ^U | awk '{print $2}'

这里有一个万无一失的方法:

grep -H -r "<<<<<<< HEAD" /path/to/project/dir

实用git向导https://github.com/makelinux/git-wizard分别计算未解决的冲突更改(冲突)和未合并的文件。冲突必须手动或使用mergetool解决。解决的未合并的更改可以添加和提交通常与git rebase -continue。

Git的状态会在有冲突的文件旁边显示“已修改”,而不是“已修改”或“新文件”等

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