Skip to content

Instantly share code, notes, and snippets.

Last active Mar 26, 2021
What would you like to do?
Git Churn command

Instructions for running on Windows 10 (via Ubuntu Bash)

  1. Open Ubuntu bash environment shell
  2. Install dependencies
    sudo apt-get update
    sudo apt-get install git curl
  3. Create bin directory in your home folder
    mkdir -p ~/bin
  4. Download git-churn script into ~/bin
    curl -o ~/bin/git-churn
  5. Mark the churn script as executable
    chmod 775 ~/bin/git-churn
  6. Switch to a cloned copy of the repository
    git churn > lifetime-churn.txt
    git churn --since='3 months ago' > recent-churn.txt
# Scriptified by Gary Bernhardt
# Slightly modified by M. Scott Ford
# Put this anywhere on your $PATH (~/bin is recommended). Then git will see it
# and you'll be able to do `git churn`.
# Show churn for whole repo:
# $ git churn
# Show churn for specific directories:
# $ git churn app lib
# Show churn for a time range:
# $ git churn --since='1 month ago'
# (These are all standard arguments to `git log`.)
# you might move this to `~/bin`, mark as executable, and then you'll be able to run it with
# `git churn`
set -e
git log --all --find-renames --find-copies --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort -n | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment