On , I learnt ...

How to count lines of code in a Git repo for a given commit

For a given commit $SHA, use:

$ git diff --shortstat `git hash-object -t tree /dev/null`..$SHA

which works as git hash-object -t tree /dev/null computes the hash of the empty tree.