Skip to content

Instantly share code, notes, and snippets.

@nickshanks
Created February 20, 2014 09:15
Show Gist options
  • Save nickshanks/9109780 to your computer and use it in GitHub Desktop.
Save nickshanks/9109780 to your computer and use it in GitHub Desktop.
Prints out a list of hashes from the master branch and their distance from the current HEAD. This is useful for finding the fork point of a tree dump you may have received via email or similar. Relies on the porcelain command diff-tree so expect it to break in future.
#!/bin/bash
HASHES=$(git rev-list master)
HASHES=($HASHES)
for HASH in "${HASHES[@]}"
do
STATS=($(git diff-tree --minimal --shortstat -w HEAD $HASH))
echo "$HASH => ${STATS[0]} files changed, $((${STATS[3]}+${STATS[5]})) lines changed (+${STATS[3]}/-${STATS[5]})"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment