Is there a simple way I can ask git for the amount of lines I added (or add and removed) in a specific date range?
I'm using git on Windows, Linux and TortoiseGit(Windows)
Building upon Seth Robertson's answer, (+1 Seth!) awk will tally up the columns for you:
% git log --stat --author $(git config --get user.email) --since="last year" --until="last month" | awk -F',' '/files? changed/ { files += $1 insertions += $2 deletions += $3 print } END { print "Files Changed: " files print "Insertions: " insertions print "Deletions: " deletions print "Lines changed: " insertions + deletions }'
awk.stat may hide deletions or insertions if there are none. If there are no insertions in that particular commit, then git may show 1 file changed, 6 deletions(-), making your script add the deletions to insertions variable.match($0, /([0-9]+) files? changed(, ([0-9]+) insertions?\(\+\))?(, ([0-9]+) deletions?\(\-\))?/, m); files += m[1]; insertions += m[3]; deletions += m[5];
--numstatoption, which gives a much more machine-readable format than--stat.awkthan '2 0 .gitconfig' and saves me tallying the number of files changed!