Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
Created September 4, 2015 21:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonsar/af929d452dc8066ec28d to your computer and use it in GitHub Desktop.
Save nelsonsar/af929d452dc8066ec28d to your computer and use it in GitHub Desktop.
Calculate distance between HEAD and a given hash
#!/bin/bash
COUNTER=1
for i in $(git log --oneline | cut -d" " -f 1); do
let COUNTER+=1
if [ "$i" = "$1" ]; then
echo "$COUNTER"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment