git rev-parse HEAD

Category: Git - Core

git rev-parse HEAD

Resolve a ref to its full commit hash

Resolves a name like HEAD, a branch, or a tag into the full 40-character object hash. Scripts use it to capture commit IDs reliably. Add --short for the abbreviated form and --abbrev-ref for branch names.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.