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

Ever wish you got more email?

Neither do I. You're busy, and so is your inbox. I'll only be in touch when I publish something new. And of course it goes without saying your email will be kept completely private.