Aedvald Tseh
Aedvald Tseh

Reputation: 1917

Files modified by two branches

In Git in master-branch I have these files:

foo1.txt
foo2.txt
bar1.txt
bar.txt

Then I create branch A and modify files foo1.txt and foo2.txt. After this I go back to master-branch and create branch B in which I modify files bar1.txt and foo1.txt. Please note that foo1.txt is the only file, which is modified by both branches A and B.

Now I would like to get a list of files, which were modified by branches A and B. This would be very helpful to check for any conflicts before I merge branch A into branch B .

I tried this, but this give me only the differences between branch A and B:

git diff A B --name-only

bar1.txt
foo1.txt
foo2.txt

How can I get get a list of files, which were modified by branches A and B ? The expected list has the only entry foo1.txt

Upvotes: 0

Views: 80

Answers (1)

cmbuckley
cmbuckley

Reputation: 42458

One way to do this would be to use comm and the diff 3 dot syntax:

comm -12 <(git diff A...B --name-only | sort) <(git diff B...A --name-only | sort)

comm -12 only shows the items that appear in both lists.

Upvotes: 2

Related Questions