FahamLah

Commands

git rev-parse

git rev-parse [--short] [--abbrev-ref] <rev>

Risk: Safe

What it does

Turns a name like HEAD~2 or main into a full commit id.

When to use it

To check what a revision name points to.

Example

$ git rev-parse HEAD~2

Print the full id of the commit two steps back.

$ git rev-parse --short HEAD

Print the short id instead.

$ git rev-parse --abbrev-ref HEAD

Print the name of your branch.

$ git rev-parse --show-toplevel

Print the top folder of this repo.