Skip to content

Instantly share code, notes, and snippets.

@therustmonk
Forked from jhradilek/.gitconfig
Created November 30, 2016 06:01
Show Gist options
  • Save therustmonk/dcdf6270bc8c6b0f369a2cd91e84eb4a to your computer and use it in GitHub Desktop.
Save therustmonk/dcdf6270bc8c6b0f369a2cd91e84eb4a to your computer and use it in GitHub Desktop.
A Git alias to display the total number of insertions and deletions.
# Usage: git total [OPTION...]
#
# Options:
#
# In theory, the command accepts all command line options supported by
# the "git log" command. In reality, however, only few commit-limiting
# options are useful. This includes:
#
# --author=PATTERN, --committer=PATTERN
# Displays the number of lines changed by a certain author.
#
# --since=DATE, --after=DATE
# Counts only commits that are more recent than a specific date.
#
# --until=DATE, --before=DATE
# Counts only commits that are older than a specific date.
#
# -n NUMBER, --max-count=NUMBER
# Counts only a certain number of commits.
#
# Examples:
#
# git total
# Displays the total number of changes.
#
# git total --author=john@example.com
# Displays the total number of changes by john@example.com.
[alias]
total = "!f() { git log $@ --numstat | perl -ne '$i+=$1 and $d+=$2 if /^(\\d+)\\s+(\\d+)/; END { print \"$i insertion(s), $d deletion(s)\n\"}'; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment