]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-symbolic-ref.txt
t4034: abstract away SHA-1-specific constants
[thirdparty/git.git] / Documentation / git-symbolic-ref.txt
CommitLineData
12905637
JH
1git-symbolic-ref(1)
2===================
3
4NAME
5----
9ab55daa 6git-symbolic-ref - Read, modify and delete symbolic refs
12905637
JH
7
8SYNOPSIS
9--------
7791a1d9 10[verse]
42b00599
JK
11'git symbolic-ref' [-m <reason>] <name> <ref>
12'git symbolic-ref' [-q] [--short] <name>
9ab55daa 13'git symbolic-ref' --delete [-q] <name>
12905637
JH
14
15DESCRIPTION
16-----------
17Given one argument, reads which branch head the given symbolic
18ref refers to and outputs its path, relative to the `.git/`
19directory. Typically you would give `HEAD` as the <name>
75f492ac 20argument to see which branch your working tree is on.
12905637 21
75f492ac 22Given two arguments, creates or updates a symbolic ref <name> to
12905637
JH
23point at the given branch <ref>.
24
9ab55daa
JH
25Given `--delete` and an additional argument, deletes the given
26symbolic ref.
27
22b1c7ee
AP
28A symbolic ref is a regular file that stores a string that
29begins with `ref: refs/`. For example, your `.git/HEAD` is
30a regular file whose contents is `ref: refs/heads/master`.
31
a0f4280f
JH
32OPTIONS
33-------
34
9ab55daa
JH
35-d::
36--delete::
37 Delete the symbolic ref <name>.
38
3240240f
SB
39-q::
40--quiet::
a0f4280f
JH
41 Do not issue an error message if the <name> is not a
42 symbolic ref but a detached HEAD; instead exit with
43 non-zero status silently.
44
42b00599
JK
45--short::
46 When showing the value of <name> as a symbolic ref, try to shorten the
47 value, e.g. from `refs/heads/master` to `master`.
48
8b5157e4
NP
49-m::
50 Update the reflog for <name> with <reason>. This is valid only
51 when creating or updating a symbolic ref.
52
22b1c7ee
AP
53NOTES
54-----
55In the past, `.git/HEAD` was a symbolic link pointing at
56`refs/heads/master`. When we wanted to switch to another branch,
57we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
12905637 58to find out which branch we are on, we did `readlink .git/HEAD`.
a8d05d72
MH
59But symbolic links are not entirely portable, so they are now
60deprecated and symbolic refs (as described above) are used by
61default.
12905637 62
0b444cdb 63'git symbolic-ref' will exit with status 0 if the contents of the
a74b1706
JK
64symbolic ref were printed correctly, with status 1 if the requested
65name is not a symbolic ref, or 128 if another error occurs.
66
12905637
JH
67GIT
68---
9e1f0a85 69Part of the linkgit:git[1] suite