Git: How to diff two different files in different branches

gitgit-diff

I have two different files in different branches.
How can I diff them in one command?

Something like

# git diff branch1/foo.txt branch2/foo-another.txt

I could check out the other file, diff it and restore, but that's quite dirty solution.

Best Answer

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