Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Copies the last commit SHA to your clipboard.
# Copy the last commit in the current branch, or if passed as a parameter, a different branch.
# See the blog post documenting the surprisingly lengthly process of building this here:
function clc {
[[ -z $1 ]] && BRANCH=$(git rev-parse --abbrev-ref HEAD) || BRANCH=$1
LAST_COMMIT_SHA=$(git rev-parse $BRANCH | tail -n 1)
echo "$LAST_COMMIT_SHA" | tr -d '\n' | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.