LinuxCommandLibrary

git-rev-parse

Parse revision and repository information

TLDR

Get commit hash

$ git rev-parse HEAD
copy
Get short hash
$ git rev-parse --short HEAD
copy
Get branch name
$ git rev-parse --abbrev-ref HEAD
copy
Get repository root
$ git rev-parse --show-toplevel
copy
Check if in git repository
$ git rev-parse --is-inside-work-tree
copy
Get git directory
$ git rev-parse --git-dir
copy
Verify object exists
$ git rev-parse --verify [ref]
copy

SYNOPSIS

git rev-parse [options] args...

DESCRIPTION

git rev-parse translates ref names, symbolic references, and other arguments into SHA-1 hashes. It also provides information about the repository structure, such as the root directory, git directory, and current branch.
This plumbing command is widely used in scripts for resolving refs and querying repository metadata.

PARAMETERS

--short [length]

Abbreviated hash.
--abbrev-ref
Show short ref name.
--verify
Verify object exists.
--show-toplevel
Show repository root.
--git-dir
Show .git directory.
--is-inside-work-tree
Check if in work tree.
--symbolic
Show symbolic name.
--symbolic-full-name
Full symbolic name.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community