Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2012 21:35
  • Star 67 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Git - calculate how many lines of code were added/changed by someone
# Run this in the project repo from the command-line
git log --shortstat --author "Xeoncross" --since "2 weeks ago" --until "1 week ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
Copy link

How do I make an alias of this? Because we use both ' and ", I do not know a syntax to get a valid command. This is what I have now:

git config --global "!git log ..."

Copy link

building on the previous solutions, if you want to skip certain files you can add -- ':!pattern'

git log --stat 0000000..HEAD -- ':!*test.go' | rg "files changed" | awk ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment