0

In a recent refactoring, I split file a.txt into b.txt and c.txt in branch1, and split it into c.txt and d.txt in branch2. When diffing, Git interprets such a split as moving e.g. a.txt to b.txt (since they have more content in common) with changes, and adding c.txt as a new file.

How can I git diff files with different names from different commits? e.g. How can I diff these with each other?

  • b.txt from branch1
  • d.txt from branch2
cp.engr
  • 2,291
  • 4
  • 28
  • 42
  • does using `git diff -M3` give `git` enough hints to follow moves? – anthony sottile Feb 02 '20 at 20:00
  • 1
    maybe this might help you with your problem https://stackoverflow.com/a/16683184/8776411 – Niklas Klausberger Feb 02 '20 at 20:07
  • @NiklasKlausberger yes, the 2nd option on the linked answer is what I was looking for. `git diff branch1:b.txt branch2:d.txt` in my example. (Except the linked answer doesn't specify both branches, as does the one it links to.) Thanks! – cp.engr Feb 02 '20 at 20:17

0 Answers0