Diff current file version and previous one remote repository

diff, git

Solution

If you're talking about a remote branch, say, `origin/master`, you can use `~` and `^` to refer to ancestor commits relative to a branch the same way you can with local branches:

# what change was introduced to origin/master in the last 4 commits?
git diff origin/master origin/master~3

If you want to diff your current working directory against the 5th most recent commit on `origin/master`, you would omit the first argument:

git diff origin/master~4

Problem

How do I diff my working file version vs. some previous version in the remote repository? Say, I pull today, perform 6 - 8 commits to my local copy and then want to see the diff between my latest working version ( of a given file ) and the latest on the remote or any other version.

Original source