Skip to content

Instantly share code, notes, and snippets.

@yhauxell
Created September 7, 2023 13:26
Show Gist options
  • Save yhauxell/96e38893d5cf02b0a00d2f68c62db330 to your computer and use it in GitHub Desktop.
Save yhauxell/96e38893d5cf02b0a00d2f68c62db330 to your computer and use it in GitHub Desktop.
Get changes stats over current branch on git repos
function git_numstat_summary() {
CURRENT=$(git branch --show-current)
FILES=$(git diff --name-only main...HEAD | wc -l)
echo "Files changed"
echo "$FILES files"
echo "Lines changed"
git log --numstat --pretty="%H" main.."$CURRENT" | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
}
alias branchstats=git_numstat_summary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment