1GIT-SYMBOLIC-REF(1) Git Manual GIT-SYMBOLIC-REF(1)
2
3
4
6 git-symbolic-ref - Read, modify and delete symbolic refs
7
9 git symbolic-ref [-m <reason>] <name> <ref>
10 git symbolic-ref [-q] [--short] <name>
11 git symbolic-ref --delete [-q] <name>
12
13
15 Given one argument, reads which branch head the given symbolic ref
16 refers to and outputs its path, relative to the .git/ directory.
17 Typically you would give HEAD as the <name> argument to see which
18 branch your working tree is on.
19
20 Given two arguments, creates or updates a symbolic ref <name> to point
21 at the given branch <ref>.
22
23 Given --delete and an additional argument, deletes the given symbolic
24 ref.
25
26 A symbolic ref is a regular file that stores a string that begins with
27 ref: refs/. For example, your .git/HEAD is a regular file whose
28 contents is ref: refs/heads/master.
29
31 -d, --delete
32 Delete the symbolic ref <name>.
33
34 -q, --quiet
35 Do not issue an error message if the <name> is not a symbolic ref
36 but a detached HEAD; instead exit with non-zero status silently.
37
38 --short
39 When showing the value of <name> as a symbolic ref, try to shorten
40 the value, e.g. from refs/heads/master to master.
41
42 -m
43 Update the reflog for <name> with <reason>. This is valid only when
44 creating or updating a symbolic ref.
45
47 In the past, .git/HEAD was a symbolic link pointing at
48 refs/heads/master. When we wanted to switch to another branch, we did
49 ln -sf refs/heads/newbranch .git/HEAD, and when we wanted to find out
50 which branch we are on, we did readlink .git/HEAD. But symbolic links
51 are not entirely portable, so they are now deprecated and symbolic refs
52 (as described above) are used by default.
53
54 git symbolic-ref will exit with status 0 if the contents of the
55 symbolic ref were printed correctly, with status 1 if the requested
56 name is not a symbolic ref, or 128 if another error occurs.
57
59 Part of the git(1) suite
60
61
62
63Git 2.24.1 12/10/2019 GIT-SYMBOLIC-REF(1)