6 git-symbolic-ref - Read and modify symbolic refs
11 'git symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
15 Given one argument, reads which branch head the given symbolic
16 ref refers to and outputs its path, relative to the `.git/`
17 directory. Typically you would give `HEAD` as the <name>
18 argument to see which branch your working tree is on.
20 Given two arguments, creates or updates a symbolic ref <name> to
21 point at the given branch <ref>.
23 A symbolic ref is a regular file that stores a string that
24 begins with `ref: refs/`. For example, your `.git/HEAD` is
25 a regular file whose contents is `ref: refs/heads/master`.
32 Do not issue an error message if the <name> is not a
33 symbolic ref but a detached HEAD; instead exit with
34 non-zero status silently.
37 Update the reflog for <name> with <reason>. This is valid only
38 when creating or updating a symbolic ref.
42 In the past, `.git/HEAD` was a symbolic link pointing at
43 `refs/heads/master`. When we wanted to switch to another branch,
44 we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
45 to find out which branch we are on, we did `readlink .git/HEAD`.
46 This was fine, and internally that is what still happens by
47 default, but on platforms that do not have working symlinks,
48 or that do not have the `readlink(1)` command, this was a bit
49 cumbersome. On some platforms, `ln -sf` does not even work as
50 advertised (horrors). Therefore symbolic links are now deprecated
51 and symbolic refs are used by default.
53 'git symbolic-ref' will exit with status 0 if the contents of the
54 symbolic ref were printed correctly, with status 1 if the requested
55 name is not a symbolic ref, or 128 if another error occurs.
59 Part of the linkgit:git[1] suite