Git · Inspection and internals

git rev-parse

Resolves a ref to a commit hash. Useful in scripts.

Syntax
git rev-parse HEAD

Example

Example
git rev-parse --short HEAD
git rev-parse --abbrev-ref HEAD

More in this group

git archive git bisect git grep git ls-files git shortlog git show-ref

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course