6 git-symbolic-ref - Read and modify symbolic refs
11 'git symbolic-ref' [-m <reason>] <name> <ref>
12 'git symbolic-ref' [-q] [--short] <name>
16 Given one argument, reads which branch head the given symbolic
17 ref refers to and outputs its path, relative to the `.git/`
18 directory. Typically you would give `HEAD` as the <name>
19 argument to see which branch your working tree is on.
21 Given two arguments, creates or updates a symbolic ref <name> to
22 point at the given branch <ref>.
24 A symbolic ref is a regular file that stores a string that
25 begins with `ref: refs/`. For example, your `.git/HEAD` is
26 a regular file whose contents is `ref: refs/heads/master`.
33 Do not issue an error message if the <name> is not a
34 symbolic ref but a detached HEAD; instead exit with
35 non-zero status silently.
38 When showing the value of <name> as a symbolic ref, try to shorten the
39 value, e.g. from `refs/heads/master` to `master`.
42 Update the reflog for <name> with <reason>. This is valid only
43 when creating or updating a symbolic ref.
47 In the past, `.git/HEAD` was a symbolic link pointing at
48 `refs/heads/master`. When we wanted to switch to another branch,
49 we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
50 to find out which branch we are on, we did `readlink .git/HEAD`.
51 But symbolic links are not entirely portable, so they are now
52 deprecated and symbolic refs (as described above) are used by
55 'git symbolic-ref' will exit with status 0 if the contents of the
56 symbolic ref were printed correctly, with status 1 if the requested
57 name is not a symbolic ref, or 128 if another error occurs.
61 Part of the linkgit:git[1] suite