Skip to content

Instantly share code, notes, and snippets.

@gonsolo
Last active March 17, 2023 08:18
Show Gist options
  • Save gonsolo/d288200e4479212135e6f29a86a4eff3 to your computer and use it in GitHub Desktop.
Save gonsolo/d288200e4479212135e6f29a86a4eff3 to your computer and use it in GitHub Desktop.
Discover insertions and deletions of an author for a specified time with git
# Print lines added by author
git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep insertions | awk '{sum += $4} END {print sum}'
# Print lines deleted by author
git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep deletions | rev | awk '{print $2}' | rev | awk '{sum += $1} END {print sum}'
# Net amount
echo $(( $(git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep insertions | awk '{sum += $4} END {print sum}') - $(git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep deletions | rev | awk '{print $2}' | rev | awk '{sum += $1} END {print sum}') ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment