Compare a single file between Git branches

August 2017

You've been working on a file for hours, and can't remember what change you've made. If the original version you'd like to look at is on a different branch, a simple git diff won't cut it. However, you can easily compare files across branches with:

git diff mybranch..otherbranch -- /path/to/file.ext

If you're actually on the branch and want to compare with another branch, there's a simpler way still:

git diff otherbranch.. -- /path/to/file.ext