blob: ef68ad2b7112d5749fd7ee090befe248ceb27204 [file] [log] [blame]
Junio C Hamano12905632005-10-04 16:45:01 -07001git-symbolic-ref(1)
2===================
3
4NAME
5----
Johan Herland9ab55da2012-10-21 13:32:33 +02006git-symbolic-ref - Read, modify and delete symbolic refs
Junio C Hamano12905632005-10-04 16:45:01 -07007
8SYNOPSIS
9--------
Martin von Zweigbergk7791a1d2011-07-01 22:38:26 -040010[verse]
Jan Krüger42b00592012-02-27 23:10:38 +010011'git symbolic-ref' [-m <reason>] <name> <ref>
12'git symbolic-ref' [-q] [--short] <name>
Johan Herland9ab55da2012-10-21 13:32:33 +020013'git symbolic-ref' --delete [-q] <name>
Junio C Hamano12905632005-10-04 16:45:01 -070014
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>
Štěpán Němec75f492a2009-08-11 02:52:07 +020020argument to see which branch your working tree is on.
Junio C Hamano12905632005-10-04 16:45:01 -070021
Štěpán Němec75f492a2009-08-11 02:52:07 +020022Given two arguments, creates or updates a symbolic ref <name> to
Junio C Hamano12905632005-10-04 16:45:01 -070023point at the given branch <ref>.
24
Johan Herland9ab55da2012-10-21 13:32:33 +020025Given `--delete` and an additional argument, deletes the given
26symbolic ref.
27
Andy Parkins22b1c7e2006-11-30 10:50:28 +000028A 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 Hamanoa0f42802007-01-15 13:56:05 -080032OPTIONS
33-------
34
Johan Herland9ab55da2012-10-21 13:32:33 +020035-d::
36--delete::
37 Delete the symbolic ref <name>.
38
Stephan Beyer32402402008-06-08 03:36:09 +020039-q::
40--quiet::
Junio C Hamanoa0f42802007-01-15 13:56:05 -080041 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
Jan Krüger42b00592012-02-27 23:10:38 +010045--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
Nicolas Pitre8b5157e2007-01-26 17:26:10 -050049-m::
50 Update the reflog for <name> with <reason>. This is valid only
51 when creating or updating a symbolic ref.
52
Andy Parkins22b1c7e2006-11-30 10:50:28 +000053NOTES
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 Hamano12905632005-10-04 16:45:01 -070058to find out which branch we are on, we did `readlink .git/HEAD`.
Michael Haggertya8d05d72011-12-07 16:20:16 +010059But symbolic links are not entirely portable, so they are now
60deprecated and symbolic refs (as described above) are used by
61default.
Junio C Hamano12905632005-10-04 16:45:01 -070062
Thomas Rast0b444cd2010-01-10 00:33:00 +010063'git symbolic-ref' will exit with status 0 if the contents of the
Jeff Kinga74b1702007-01-15 17:25:33 -050064symbolic 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 Hamano12905632005-10-04 16:45:01 -070067GIT
68---
Christian Couder9e1f0a82008-06-06 09:07:32 +020069Part of the linkgit:git[1] suite