1GIT-SYMBOLIC-REF(1)               Git Manual               GIT-SYMBOLIC-REF(1)
2
3
4

NAME

6       git-symbolic-ref - Read, modify and delete symbolic refs
7

SYNOPSIS

9       git symbolic-ref [-m <reason>] <name> <ref>
10       git symbolic-ref [-q] [--short] [--no-recurse] <name>
11       git symbolic-ref --delete [-q] <name>
12

DESCRIPTION

14       Given one argument, reads which branch head the given symbolic ref
15       refers to and outputs its path, relative to the .git/ directory.
16       Typically you would give HEAD as the <name> argument to see which
17       branch your working tree is on.
18
19       Given two arguments, creates or updates a symbolic ref <name> to point
20       at the given branch <ref>.
21
22       Given --delete and an additional argument, deletes the given symbolic
23       ref.
24
25       A symbolic ref is a regular file that stores a string that begins with
26       ref: refs/. For example, your .git/HEAD is a regular file whose content
27       is ref: refs/heads/master.
28

OPTIONS

30       -d, --delete
31           Delete the symbolic ref <name>.
32
33       -q, --quiet
34           Do not issue an error message if the <name> is not a symbolic ref
35           but a detached HEAD; instead exit with non-zero status silently.
36
37       --short
38           When showing the value of <name> as a symbolic ref, try to shorten
39           the value, e.g. from refs/heads/master to master.
40
41       --recurse, --no-recurse
42           When showing the value of <name> as a symbolic ref, if <name>
43           refers to another symbolic ref, follow such a chain of symbolic
44           refs until the result no longer points at a symbolic ref
45           (--recurse, which is the default).  --no-recurse stops after
46           dereferencing only a single level of symbolic ref.
47
48       -m
49           Update the reflog for <name> with <reason>. This is valid only when
50           creating or updating a symbolic ref.
51

NOTES

53       In the past, .git/HEAD was a symbolic link pointing at
54       refs/heads/master. When we wanted to switch to another branch, we did
55       ln -sf refs/heads/newbranch .git/HEAD, and when we wanted to find out
56       which branch we are on, we did readlink .git/HEAD. But symbolic links
57       are not entirely portable, so they are now deprecated and symbolic refs
58       (as described above) are used by default.
59
60       git symbolic-ref will exit with status 0 if the contents of the
61       symbolic ref were printed correctly, with status 1 if the requested
62       name is not a symbolic ref, or 128 if another error occurs.
63

GIT

65       Part of the git(1) suite
66
67
68
69Git 2.43.0                        11/20/2023               GIT-SYMBOLIC-REF(1)
Impressum