Documentation / git-checkout-index.txton commit Merge branch 'master' into next (8d6afc1)
   1git-checkout-index(1)
   2=====================
   3
   4NAME
   5----
   6git-checkout-index - Copy files from the index to the working directory
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
  13                   [--stage=<number>]
  14                   [-z] [--stdin]
  15                   [--] [<file>]\*
  16
  17DESCRIPTION
  18-----------
  19Will copy all files listed from the index to the working directory
  20(not overwriting existing files).
  21
  22OPTIONS
  23-------
  24-u|--index::
  25        update stat information for the checked out entries in
  26        the index file.
  27
  28-q|--quiet::
  29        be quiet if files exist or are not in the index
  30
  31-f|--force::
  32        forces overwrite of existing files
  33
  34-a|--all::
  35        checks out all files in the index.  Cannot be used
  36        together with explicit filenames.
  37
  38-n|--no-create::
  39        Don't checkout new files, only refresh files already checked
  40        out.
  41
  42--prefix=<string>::
  43        When creating files, prepend <string> (usually a directory
  44        including a trailing /)
  45
  46--stage=<number>::
  47        Instead of checking out unmerged entries, copy out the
  48        files from named stage.  <number> must be between 1 and 3.
  49
  50--stdin::
  51        Instead of taking list of paths from the command line,
  52        read list of paths from the standard input.  Paths are
  53        separated by LF (i.e. one path per line) by default.
  54
  55-z::
  56        Only meaningful with `--stdin`; paths are separated with
  57        NUL character instead of LF.
  58
  59--::
  60        Do not interpret any more arguments as options.
  61
  62The order of the flags used to matter, but not anymore.
  63
  64Just doing `git-checkout-index` does nothing. You probably meant
  65`git-checkout-index -a`. And if you want to force it, you want
  66`git-checkout-index -f -a`.
  67
  68Intuitiveness is not the goal here. Repeatability is. The reason for
  69the "no arguments means no work" behavior is that from scripts you are
  70supposed to be able to do:
  71
  72----------------
  73$ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
  74----------------
  75
  76which will force all existing `*.h` files to be replaced with their
  77cached copies. If an empty command line implied "all", then this would
  78force-refresh everything in the index, which was not the point.  But
  79since git-checkout-index accepts --stdin it would be faster to use:
  80
  81----------------
  82$ find . -name '*.h' -print0 | git-checkout-index -f -z --stdin
  83----------------
  84
  85The `--` is just a good idea when you know the rest will be filenames;
  86it will prevent problems with a filename of, for example,  `-a`.
  87Using `--` is probably a good policy in scripts.
  88
  89
  90EXAMPLES
  91--------
  92To update and refresh only the files already checked out::
  93+
  94----------------
  95$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
  96----------------
  97
  98Using `git-checkout-index` to "export an entire tree"::
  99        The prefix ability basically makes it trivial to use
 100        `git-checkout-index` as an "export as tree" function.
 101        Just read the desired tree into the index, and do:
 102+
 103----------------
 104$ git-checkout-index --prefix=git-export-dir/ -a
 105----------------
 106+
 107`git-checkout-index` will "export" the index into the specified
 108directory.
 109+
 110The final "/" is important. The exported name is literally just
 111prefixed with the specified string.  Contrast this with the
 112following example.
 113
 114Export files with a prefix::
 115+
 116----------------
 117$ git-checkout-index --prefix=.merged- Makefile
 118----------------
 119+
 120This will check out the currently cached copy of `Makefile`
 121into the file `.merged-Makefile`.
 122
 123
 124Author
 125------
 126Written by Linus Torvalds <torvalds@osdl.org>
 127
 128
 129Documentation
 130--------------
 131Documentation by David Greaves,
 132Junio C Hamano and the git-list <git@vger.kernel.org>.
 133
 134
 135GIT
 136---
 137Part of the gitlink:git[7] suite
 138