What's the simplest way to list conflicted files in Git?
git diff --name-only --diff-filter=U
git diff --check
will show the list of files containing conflict markers including line numbers.
For example:
> 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
source : https://ardalis.com/detect-git-conflict-markers
Trying to answer my question:
No, there doesn't seem to be any simpler way than the one in the question, out of box.
After typing that in too many times, just pasted the shorter one into an executable file named 'git-conflicts', made accessible to git, now I can just:
git conflicts
to get the list I wanted.
Update: as Richard suggests, you can set up an git alias, as alternative to the executable
git config --global alias.conflicts '!git ls-files -u | cut -f 2 | sort -u'
An advantage of using the executable over the alias is that you can share that script with team members (in a bin dir part of the repo).