blob: 102c83eb19e98a7c14f8de879cca93d610b5fd34 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-symbolic-ref(1)
2===================
3
4NAME
5----
Junio C Hamano4eb2b9c2012-11-15 21:12:296git-symbolic-ref - Read, modify and delete symbolic refs
Junio C Hamano1a4e8412005-12-27 08:17:237
8SYNOPSIS
9--------
Junio C Hamano15567bc2011-07-23 00:51:5910[verse]
Junio C Hamano3dd93922012-03-05 07:49:1111'git symbolic-ref' [-m <reason>] <name> <ref>
Junio C Hamano3393baa2022-10-21 20:48:2112'git symbolic-ref' [-q] [--short] [--no-recurse] <name>
Junio C Hamano4eb2b9c2012-11-15 21:12:2913'git symbolic-ref' --delete [-q] <name>
Junio C Hamano1a4e8412005-12-27 08:17:2314
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>
Junio C Hamano9f883862009-08-11 06:23:5220argument to see which branch your working tree is on.
Junio C Hamano1a4e8412005-12-27 08:17:2321
Junio C Hamano9f883862009-08-11 06:23:5222Given two arguments, creates or updates a symbolic ref <name> to
Junio C Hamano1a4e8412005-12-27 08:17:2323point at the given branch <ref>.
24
Junio C Hamano4eb2b9c2012-11-15 21:12:2925Given `--delete` and an additional argument, deletes the given
26symbolic ref.
27
Junio C Hamano735a4f72006-12-03 01:53:3228A 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
Junio C Hamano97c11c52007-01-16 10:44:4732OPTIONS
33-------
34
Junio C Hamano4eb2b9c2012-11-15 21:12:2935-d::
36--delete::
37Delete the symbolic ref <name>.
38
Junio C Hamanoeb415992008-06-08 22:49:4739-q::
40--quiet::
Junio C Hamano97c11c52007-01-16 10:44:4741Do not issue an error message if the <name> is not a
42symbolic ref but a detached HEAD; instead exit with
43non-zero status silently.
44
Junio C Hamano3dd93922012-03-05 07:49:1145--short::
46When showing the value of <name> as a symbolic ref, try to shorten the
47value, e.g. from `refs/heads/master` to `master`.
48
Junio C Hamano3393baa2022-10-21 20:48:2149--recurse::
50--no-recurse::
51When showing the value of <name> as a symbolic ref, if
52<name> refers to another symbolic ref, follow such a chain
53of symbolic refs until the result no longer points at a
54symbolic ref (`--recurse`, which is the default).
55`--no-recurse` stops after dereferencing only a single level
56of symbolic ref.
57
Junio C Hamano16cf1582007-02-05 07:21:4858-m::
59Update the reflog for <name> with <reason>. This is valid only
60when creating or updating a symbolic ref.
61
Junio C Hamano735a4f72006-12-03 01:53:3262NOTES
63-----
64In the past, `.git/HEAD` was a symbolic link pointing at
65`refs/heads/master`. When we wanted to switch to another branch,
66we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
Junio C Hamano1a4e8412005-12-27 08:17:2367to find out which branch we are on, we did `readlink .git/HEAD`.
Junio C Hamano515ab1d2011-12-09 23:41:2068But symbolic links are not entirely portable, so they are now
69deprecated and symbolic refs (as described above) are used by
70default.
Junio C Hamano1a4e8412005-12-27 08:17:2371
Junio C Hamano1aa40d22010-01-21 17:46:4372'git symbolic-ref' will exit with status 0 if the contents of the
Junio C Hamano97c11c52007-01-16 10:44:4773symbolic ref were printed correctly, with status 1 if the requested
74name is not a symbolic ref, or 128 if another error occurs.
75
Junio C Hamano1a4e8412005-12-27 08:17:2376GIT
77---
Junio C Hamanof7c042d2008-06-06 22:50:5378Part of the linkgit:git[1] suite