0

Once I execute the git merge A B command, I can get the list of conflicting files using linux command like

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

But, is there a way to get conflicting code snippets along with file names? I want to create a report with just the conflicting code snippets.

For example, I need a report like this

src/com/xyz/ABC.java
<<<<<<< Branch_A
    this.codeFromA();
=======
    this.codeFromB();
>>>>>>>  Branch_B

..and the same section repeats for all conflicting files.

Note that there are other lines in the files. But, only the conflicting code piece is returned.

vivek_ganesan
  • 658
  • 4
  • 19
  • Possibly related: http://stackoverflow.com/questions/16573555/show-conflict-diff-part-of-a-merge ? – Holloway Oct 19 '16 at 14:12
  • @Holloway The answer in the thread you pointed to shows all diffs. Whereas i want only the conflicting diffs. Thanks for the pointer though :) – vivek_ganesan Oct 19 '16 at 14:49

2 Answers2

1

Just run git diff.

Here is explained how it works:

Since Git stages any merge results that are successful, when you run git diff while in a conflicted merge state, you only get what is currently still in conflict

max630
  • 8,762
  • 3
  • 30
  • 55
0

If you are using eclipse, you can get this information from Git staging view.

Prabodh Mhalgi
  • 805
  • 9
  • 25
  • I am trying to get this report by running a script on a Jenkins server. So, I will not have access to Eclipse that way. Thanks for the pointer :) – vivek_ganesan Oct 20 '16 at 10:26