The script runs cloc on each commit in your current branch, starting from HEAD tracing back until the first commit.
For large repositories with many commits, you can tell it to only count every n:th commit with the '--step' option to speed up processing.
The way it works is quite sub-optimal, since every single file is counted in each commit, even if the file didn't change since last iteration. Might be a fun project later to find some nice optimizations, maybe by counting files one by one and keeping a dict of line count by file hash, or something along those lines.
Maybe someone will find this script useful, maybe not, anyways happy to hear if someone has any thoughts :)