Git: How to diff two different files in different branches?
git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt
You can also use relative paths:
git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt
Sidenote: no need for full paths, you can start with ./
for relative paths. It can be handy sometimes.
git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt
Off-topic answer -- see comments
Just to add it for I find it a very straightforward syntax :
git diff <branch1> <branch2> <filepath>
Also works with relative refs like for example :
# compare the previous committed state from HEAD with the state branch1 was 3 commits ago
git diff HEAD^ <branch1>~3 <filepath>