How to diff one file to an arbitrary version in Git?

Question

How can I diff a file, say pom.xml, from the master branch to an arbitrary older version in Git?

Answer

You can do:

git diff master~20:pom.xml pom.xml

... to compare your current pom.xml to the one from master 20 revisions ago through the first parent. You can replace master~20, of course, with the object name (SHA1sum) of a commit or any of the many other ways of specifying a revision.

Note that this is actually comparing the old pom.xml to the version in your working tree, not the version committed in master. If you want that, then you can do the following instead:

git diff master~20:pom.xml master:pom.xml

Why is Github asking for username/password when following the instructions on screen and pushing a new repo?

What is git tag, How to create tags & How to checkout git remote tag(s)