GIT-SYMBOLIC-REF(1)
π GIT-SYMBOLIC-REF(1) π
okay bestie, welcome to the Git Manual page for git-symbolic-ref β the little command that reads, modifies and deletes symbolic refs, and honestly it's giving quiet-main-character energy. no cap. π
β¨ SYNOPSIS β¨
git symbolic-ref [-m <reason>] <name> <ref>
git symbolic-ref [-q] [--short] [--no-recurse] <name>
git symbolic-ref --delete [-q] <name>
πΈ DESCRIPTION πΈ
so here's the vibe check π:
one argument β it reads which branch head the given symbolic ref refers to and prints out its path, relative to the .git/ directory. and like, the classic move? you pass HEAD as the <name> argument to find out which branch your working tree is on. literally the "where am i" of git π§
two arguments β it creates or updates a symbolic ref <name> so it points at the given branch <ref>. slay, you're now pointing at a new thing π«
--delete plus one more argument β it deletes the given symbolic ref. bye bestie π
and what even is a symbolic ref? great question, obsessed that you asked π«Ά β it's a regular file that stores a string starting with ref: refs/. for example, your .git/HEAD is a regular file whose content is:
ref: refs/heads/master
periodt. that's it. that's the whole file. π
β OPTIONS β
-d,--deleteβ deletes the symbolic ref<name>. gone, deleted, not coming back π-q,--quietβ don't be loud about it: if<name>isn't a symbolic ref but a detachedHEAD, it won't throw an error message at you. instead it just exits with a non-zero status, silently. (the quiet quitting of exit codes π)--shortβ when showing the value of<name>as a symbolic ref, it tries to shorten the value β like fromrefs/heads/masterto justmaster. cute little glow-down β¨--recurse,--no-recurseβ when showing the value of<name>as a symbolic ref, if<name>refers to another symbolic ref, it follows that chain of symbolic refs until the result no longer points at a symbolic ref. that's--recurse, and it's the default (she's thorough π ).--no-recursestops after dereferencing only a single level of symbolic ref β one hop and we're done π¦-mβ updates the reflog for<name>with<reason>. only valid when you're creating or updating a symbolic ref, so don't try it on the read side, bestie π«
π¦ NOTES π¦
storytime, gather round π β in the past, .git/HEAD was a symbolic link pointing at refs/heads/master. when we wanted to switch branches we did:
ln -sf refs/heads/newbranch .git/HEAD
and when we wanted to know which branch we were on, we did:
readlink .git/HEAD
but here's the tea β β symbolic links are not entirely portable, so they are now deprecated, and symbolic refs (like the ones described above) are used by default. rip to the symlink era, she was iconic but problematic π
β οΈ exit status check, iykyk:git symbolic-refexits with status0if the contents of the symbolic ref were printed correctly, status1if the requested name is not a symbolic ref, or128if another error occurs. memorise it, it WILL come up π₯
π SEE ALSO π
git-update-ref(1)β go read that one too, bestie π«Ά
π§ GIT π§
part of the git(1) suite. obviously. the whole family is iconic π
and that's the page!! brought to you by Git 2.56.0, dated 2026-09-27 β mwah, go read a symbolic ref and tell her she's pretty πβ¨
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms