Copy Git commit SHA hash


Get most recent Git commit SHA-1 hash from HEAD:

git log --oneline | head -1 | awk '{print $1}'

Copy Git commit SHA-1 hash to macOS clipboard:

git log --oneline | head -1 | awk '{print $1}' | pbcopy

Alternative command:

git log -1 --format=format:%H | pbcopy


Please support this site and join our Discord!