Documentation / git-symbolic-ref.txton commit Merge branch 'gp/branch' (5c088a2)
   1git-symbolic-ref(1)
   2===================
   3
   4NAME
   5----
   6git-symbolic-ref - Read and modify symbolic refs
   7
   8SYNOPSIS
   9--------
  10'git-symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
  11
  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
  22A 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
  26OPTIONS
  27-------
  28
  29-q::
  30        Do not issue an error message if the <name> is not a
  31        symbolic ref but a detached HEAD; instead exit with
  32        non-zero status silently.
  33
  34-m::
  35        Update the reflog for <name> with <reason>.  This is valid only
  36        when creating or updating a symbolic ref.
  37
  38NOTES
  39-----
  40In the past, `.git/HEAD` was a symbolic link pointing at
  41`refs/heads/master`.  When we wanted to switch to another branch,
  42we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we wanted
  43to find out which branch we are on, we did `readlink .git/HEAD`.
  44This was fine, and internally that is what still happens by
  45default, but on platforms that do not have working symlinks,
  46or that do not have the `readlink(1)` command, this was a bit
  47cumbersome.  On some platforms, `ln -sf` does not even work as
  48advertised (horrors).  Therefore symbolic links are now deprecated
  49and symbolic refs are used by default.
  50
  51git-symbolic-ref will exit with status 0 if the contents of the
  52symbolic ref were printed correctly, with status 1 if the requested
  53name is not a symbolic ref, or 128 if another error occurs.
  54
  55Author
  56------
  57Written by Junio C Hamano <junkio@cox.net>
  58
  59GIT
  60---
  61Part of the gitlink:git[7] suite