blob: ef68ad2b7112d5749fd7ee090befe248ceb27204 [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>
12'git symbolic-ref' [-q] [--short] <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 Hamano16cf1582007-02-05 07:21:4849-m::
50Update the reflog for <name> with <reason>. This is valid only
51when creating or updating a symbolic ref.
52
Junio C Hamano735a4f72006-12-03 01:53:3253NOTES
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
Junio C Hamano1a4e8412005-12-27 08:17:2358to find out which branch we are on, we did `readlink .git/HEAD`.
Junio C Hamano515ab1d2011-12-09 23:41:2059But symbolic links are not entirely portable, so they are now
60deprecated and symbolic refs (as described above) are used by
61default.
Junio C Hamano1a4e8412005-12-27 08:17:2362
Junio C Hamano1aa40d22010-01-21 17:46:4363'git symbolic-ref' will exit with status 0 if the contents of the
Junio C Hamano97c11c52007-01-16 10:44:4764symbolic ref were printed correctly, with status 1 if the requested
65name is not a symbolic ref, or 128 if another error occurs.
66
Junio C Hamano1a4e8412005-12-27 08:17:2367GIT
68---
Junio C Hamanof7c042d2008-06-06 22:50:5369Part of the linkgit:git[1] suite