Skip to content

Instantly share code, notes, and snippets.

@lehnerpat
Created November 15, 2012 12:23
Show Gist options
  • Save lehnerpat/4078395 to your computer and use it in GitHub Desktop.
Save lehnerpat/4078395 to your computer and use it in GitHub Desktop.
Script to replace full shas with shorter versions (arbitrary length)
#!/bin/bash
git log --format=">%H< %cN" -10 | while read line
do
pre=`echo $line|sed -e "s/\(.*\)>[^<]*<.*/\1/"`
sha=`echo $line|sed -e "s/.*>\([0-9a-fA-F]*\)<.*/\1/"`
#echo "Cut sha as: $sha"
sha=`git rev-parse --short=4 $sha`
rest=`echo $line|sed -e "s/.*>[^<]*<\(.*\)/\1/"`
echo "$pre -- $sha -- $rest"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment