How to count number of lines of code in a Git repository? Add this alias to your ~/.gitconfig
[alias] loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904
This shows diff against empty repository (
git hash-object -t tree /dev/null)
Now you can just type
git loc and get an answer. This is nice as it does not take binary files into account when counting lines.