Merge branch 'lt/rev-list' into next
[git.git] / Documentation / git-checkout-index.txt
1 git-checkout-index(1)
2 =====================
3
4 NAME
5 ----
6 git-checkout-index - Copy files from the index to the working directory
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
13                    [--stage=<number>]
14                    [-z] [--stdin]
15                    [--] [<file>]\*
16
17 DESCRIPTION
18 -----------
19 Will copy all files listed from the index to the working directory
20 (not overwriting existing files).
21
22 OPTIONS
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
62 The order of the flags used to matter, but not anymore.
63
64 Just 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
68 Intuitiveness is not the goal here. Repeatability is. The reason for
69 the "no arguments means no work" behavior is that from scripts you are
70 supposed to be able to do:
71
72 ----------------
73 $ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
74 ----------------
75
76 which will force all existing `*.h` files to be replaced with their
77 cached copies. If an empty command line implied "all", then this would
78 force-refresh everything in the index, which was not the point.  But
79 since 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
85 The `--` is just a good idea when you know the rest will be filenames;
86 it will prevent problems with a filename of, for example,  `-a`.
87 Using `--` is probably a good policy in scripts.
88
89
90 EXAMPLES
91 --------
92 To 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
98 Using `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
108 directory.
109 +
110 The final "/" is important. The exported name is literally just
111 prefixed with the specified string.  Contrast this with the
112 following example.
113
114 Export files with a prefix::
115 +
116 ----------------
117 $ git-checkout-index --prefix=.merged- Makefile
118 ----------------
119 +
120 This will check out the currently cached copy of `Makefile`
121 into the file `.merged-Makefile`.
122
123
124 Author
125 ------
126 Written by Linus Torvalds <torvalds@osdl.org>
127
128
129 Documentation
130 --------------
131 Documentation by David Greaves,
132 Junio C Hamano and the git-list <git@vger.kernel.org>.
133
134
135 GIT
136 ---
137 Part of the gitlink:git[7] suite
138