LinuxCommandLibrary

git-symbolic-ref

Read and modify symbolic references like HEAD

TLDR

Show HEAD target

$ git symbolic-ref HEAD
copy
Set HEAD to branch
$ git symbolic-ref HEAD refs/heads/main
copy
Get short name
$ git symbolic-ref --short HEAD
copy
Delete symbolic ref
$ git symbolic-ref -d HEAD
copy

SYNOPSIS

git symbolic-ref [options] name [ref]

DESCRIPTION

git symbolic-ref reads and modifies symbolic references. HEAD is the most common symbolic ref, pointing to the currently checked-out branch. This plumbing command shows which branch HEAD points to or changes it programmatically.
When HEAD is detached (pointing directly to a commit rather than a branch), this command will report an error, distinguishing it from `git rev-parse`.

PARAMETERS

NAME

Symbolic ref name (usually HEAD).
REF
Target ref to set.
--short
Show short name.
-d, --delete
Delete symbolic ref.
-q, --quiet
Quiet mode.
--help
Display help information.

CAVEATS

Plumbing command. HEAD is most common use. Detached HEAD is not a symbolic ref.

HISTORY

git symbolic-ref is a core Git plumbing command for managing symbolic references, fundamental to branch tracking.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community