Skip to content

Instantly share code, notes, and snippets.

@jmatth11
Last active February 7, 2018 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmatth11/eb269c35acf83eec30b927eef65cbd4d to your computer and use it in GitHub Desktop.
Save jmatth11/eb269c35acf83eec30b927eef65cbd4d to your computer and use it in GitHub Desktop.
convenient git show in bash
# allows user to git show by the number the commit appears in git log
# 1 is the first commit, 2 is the second, etc...
git_show() {
re='^[0-9]+$'
if ! [[ $1 =~ $re ]]; then
return
fi
sha="$(git log -$1 --format="%H")"
shaSplit=(${sha//\n/ })
git show ${shaSplit[$(($1 - 1))]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment