33

While merging some of the files failed to merge.

git status

shows both the successful and failed merges.

How to view only the unsuccessful merge files(conflict).

Currently i am using the following command to do this

 find . -name '*.cpp' -o -name '*.h' | xargs grep -l '<<<<'
37
git diff

This will only show failed merges after an unsuccessful merge. It has many options to configure what information you want to see. I suspect this is the exact option you are after:

 git diff --name-status --diff-filter=U

Also see http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#resolving-a-merge and http://www.kernel.org/pub/software/scm/git/docs/git-diff.html

  • 9
    If you want a clean list of files without the preceding U, then you can call git diff --name-only --diff-filter=U. This way you can pipe the output, for example do git diff --name-only --diff-filter=U | xargs subl. – JHannes Oct 21 '15 at 12:21
9

Try this:

$ git ls-files -u
see man-git-ls-files
7
git --no-pager diff --name-only --diff-filter=U

But since the goal is most likely to edit those files, the following will do perfect:

vim $(git diff --name-only --diff-filter=U)

Thanks to @JHannes from another answer's comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.