Search code examples
gitgit-diff

Git diff between 2 different files on the same branch


I have 2 different files foo and bar.

Each one is on 2 different commits, on the same branch, respectively with SHA1 SHA1-foo and SHA1-bar. I want to see a diff between those 2 files.

I could checkout one of the files and copy it but maybe there's a better way.


Solution

  • I found that it works the same way as branches, see this SO thread.

    git diff SHA1-foo:/path/to/foo SHA1-bar:/path/to/bar