Skip to content

Instantly share code, notes, and snippets.

@abhi1010
Created September 16, 2015 15:05
Show Gist options
  • Save abhi1010/ea0dc4179b003025fa29 to your computer and use it in GitHub Desktop.
Save abhi1010/ea0dc4179b003025fa29 to your computer and use it in GitHub Desktop.
git stats by timelines - number of lines added, removed
git log --oneline --shortstat | tee /tmp/2
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}' > /tmp/1 &
git log --since="1 year ago" --pretty=tformat: --numstat | awk '{ if ( $2 != 0 && $1 != 0 ) print $0 }' | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }'
git log --since="2 year ago" --pretty=tformat: --numstat | awk '{ if ( $2 != 0 && $1 != 0 ) print $0 }' | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }'
git log --after="2014-1-1" --before="2014-12-31" --pretty=tformat: --numstat | awk '{ if ( $2 != 0 && $1 != 0 ) print $0 }' | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines: %s Removed lines: %s Total # of lines: %s\n", add, subs, loc }'
git log --after="2015-1-1" --before="2015-12-31" --pretty=tformat: --numstat | awk '{ if ( $2 != 0 && $1 != 0 ) print $0 }' | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines: %s Removed lines: %s Total # of lines: %s\n", add, subs, loc }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment