Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
Created February 16, 2011 19:04
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save coreyhaines/829932 to your computer and use it in GitHub Desktop.
Save coreyhaines/829932 to your computer and use it in GitHub Desktop.
Bash script to generate churn counts in git repo
churn number and file name
git log --all -M -C --name-only | grep -E '^(app|lib)/' | sort | uniq -c | sort | awk 'BEGIN {print "count,file"} {print $1 "," $2}'
churn number and file name w/ limiting to last n commits
git log --all -n 5000 -M -C --name-only | grep -E '^spec/models' | sort | uniq -c | sort | awk 'BEGIN {print "count,file"} {print $1 "," $2}'
graph of churn number and frequency
git log --all -M -C --name-only | grep -E '^(app|lib)/' | sort | uniq -c | sort | awk '{print $1}' | uniq -c | sort | awk 'BEGIN { print "frequency,churn_count"} { print $1,$2}'
@fuhrmanator
Copy link

I just found https://github.com/AnAppAMonth/git-churn, which is a python solution giving a more detailed interpretation of churn (additions, subtractions).

@flacle
Copy link

flacle commented Nov 2, 2020

Solutions that I've found online looked at changes to files irrespective whether these are new changes or edits to existing lines of code. Hence I made this solution: https://github.com/flacle/truegitcodechurn/

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