How to diff one file to an arbitrary version in Git?
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
git diff <revision> <path>
For example:
git diff b0d14a4 foobar.txt