blob: 3d3a059c5e2e91bff2de173c5d6f8107d10b7e62 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-symbolic-ref(1)
2===================
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-symbolic-ref - Read and modify symbolic refs
Junio C Hamano1a4e8412005-12-27 08:17:237
8SYNOPSIS
9--------
Junio C Hamano16cf1582007-02-05 07:21:4810'git-symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
Junio C Hamano1a4e8412005-12-27 08:17:2311
12DESCRIPTION
13-----------
14Given one argument, reads which branch head the given symbolic
15ref refers to and outputs its path, relative to the `.git/`
16directory. Typically you would give `HEAD` as the <name>
17argument to see on which branch your working tree is on.
18
19Give two arguments, create or update a symbolic ref <name> to
20point at the given branch <ref>.
21
Junio C Hamano735a4f72006-12-03 01:53:3222A symbolic ref is a regular file that stores a string that
23begins with `ref: refs/`. For example, your `.git/HEAD` is
24a regular file whose contents is `ref: refs/heads/master`.
25
Junio C Hamano97c11c52007-01-16 10:44:4726OPTIONS
27-------
28
Junio C Hamanoeb415992008-06-08 22:49:4729-q::
30--quiet::
Junio C Hamano97c11c52007-01-16 10:44:4731Do not issue an error message if the <name> is not a
32symbolic ref but a detached HEAD; instead exit with
33non-zero status silently.
34
Junio C Hamano16cf1582007-02-05 07:21:4835-m::
36Update the reflog for <name> with <reason>. This is valid only
37when creating or updating a symbolic ref.
38
Junio C Hamano735a4f72006-12-03 01:53:3239NOTES
40-----
41In the past, `.git/HEAD` was a symbolic link pointing at
42`refs/heads/master`. When we wanted to switch to another branch,
43we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
Junio C Hamano1a4e8412005-12-27 08:17:2344to find out which branch we are on, we did `readlink .git/HEAD`.
45This was fine, and internally that is what still happens by
46default, but on platforms that do not have working symlinks,
47or that do not have the `readlink(1)` command, this was a bit
48cumbersome. On some platforms, `ln -sf` does not even work as
Junio C Hamano735a4f72006-12-03 01:53:3249advertised (horrors). Therefore symbolic links are now deprecated
50and symbolic refs are used by default.
Junio C Hamano1a4e8412005-12-27 08:17:2351
Junio C Hamano97c11c52007-01-16 10:44:4752git-symbolic-ref will exit with status 0 if the contents of the
53symbolic ref were printed correctly, with status 1 if the requested
54name is not a symbolic ref, or 128 if another error occurs.
55
Junio C Hamano1a4e8412005-12-27 08:17:2356Author
57------
58Written by Junio C Hamano <junkio@cox.net>
59
60GIT
61---
Junio C Hamanof7c042d2008-06-06 22:50:5362Part of the linkgit:git[1] suite