How can I diff a file, say pom.xml
, from the master branch to an arbitrary older 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