Last active
February 7, 2018 04:04
-
-
Save jmatth11/eb269c35acf83eec30b927eef65cbd4d to your computer and use it in GitHub Desktop.
convenient git show in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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