Search code examples
gitpowershellforeachdiffgit-diff

How to show the diff in all files having leftover conflict marker?


I know git diff --check will list all files having leftover conflict marker, but it doesn't actually show the diff. I think the command to show the diff in all files having leftover conflict marker should be something similar to:

git diff --check | ForEach-Object {git diff $_} 

Any idea?


Solution

  • Judging by this blog post, git diff --check produces output lines such as the following:

    demo.txt:3: leftover conflict marker
    

    Therefore, adapt your solution attempt as follows:

    git diff --check | ForEach-Object { git diff $_.Split(':')[0] }
    

    That is, split each output line into tokens by :, and use the first token as the file name to pass to git diff.