Skip to content

Instantly share code, notes, and snippets.

@keeferrourke
Created June 25, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keeferrourke/15c304a36e4ec09b44e08821a102c696 to your computer and use it in GitHub Desktop.
Save keeferrourke/15c304a36e4ec09b44e08821a102c696 to your computer and use it in GitHub Desktop.
Pretty print total added, removed, and contrib lines of code in a git repo for a user.
#!/usr/bin/env bash
# git-loccount.sh
# Pretty prints the total added, removed, and contributed lines of code for a given user
# in a git repository.
#
# Arguments:
# $1 - username
# $2 - directory to check
if ! [ -z "$2" ]; then cd "$2"; fi
git log --author="$1" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment