Shorthand for getting the diff from the last N commits?

From the SPECIFYING REVISIONS of the git rev-parse man page:

A suffix ~<n> to a revision parameter means the commit object that is the <n>th generation grand-parent of the named commit object, following only the first parent.
I.e. rev~3 is equivalent to rev^^^ which is equivalent to rev^1^1^1.

Consider the examples in the git diff man page:

git diff HEAD^..HEAD
git diff HEAD^..
git diff HEAD^ HEAD

are equivalent forms (thanks chrisk for the HEAD^.. form, as mentioned in the comments).
(they are not equivalent to git diff HEAD^, as Mark Longair comments, since it diff with the working directory, not the last commit)

So:

git diff HEAD~15       # diff the working tree with the 15th previous commit
git diff HEAD~15 HEAD  # diff the last commit  with the 15th previous commit

should do what you need (as khmarbaise mentions in the comment).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)