Documentation / git-symbolic-ref.txton commit Merge git://git.kernel.org/pub/scm/gitk/gitk (a549e11)
   1git-symbolic-ref(1)
   2===================
   3
   4NAME
   5----
   6git-symbolic-ref - read and modify symbolic refs
   7
   8SYNOPSIS
   9--------
  10'git-symbolic-ref' <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
  22Traditionally, `.git/HEAD` is a symlink pointing at
  23`refs/heads/master`.  When we want to switch to another branch,
  24we did `ln -sf refs/heads/newbranch .git/HEAD`, and when we want
  25to find out which branch we are on, we did `readlink .git/HEAD`.
  26This was fine, and internally that is what still happens by
  27default, but on platforms that do not have working symlinks,
  28or that do not have the `readlink(1)` command, this was a bit
  29cumbersome.  On some platforms, `ln -sf` does not even work as
  30advertised (horrors).
  31
  32A symbolic ref can be a regular file that stores a string that
  33begins with `ref: refs/`.  For example, your `.git/HEAD` *can*
  34be a regular file whose contents is `ref: refs/heads/master`.
  35This can be used on a filesystem that does not support symbolic
  36links.  Instead of doing `readlink .git/HEAD`, `git-symbolic-ref
  37HEAD` can be used to find out which branch we are on.  To point
  38the HEAD to `newbranch`, instead of `ln -sf refs/heads/newbranch
  39.git/HEAD`, `git-symbolic-ref HEAD refs/heads/newbranch` can be
  40used.
  41
  42Currently, .git/HEAD uses a regular file symbolic ref on Cygwin,
  43and everywhere else it is implemented as a symlink.  This can be
  44changed at compilation time.
  45
  46Author
  47------
  48Written by Junio C Hamano <junkio@cox.net>
  49
  50GIT
  51---
  52Part of the gitlink:git[7] suite