Documentation: sync git.txt command list and manual page title
[git/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 tree
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
13 [--stage=<number>|all]
14 [--temp]
15 [-z] [--stdin]
16 [--] [<file>]\*
17
18 DESCRIPTION
19 -----------
20 Will copy all files listed from the index to the working directory
21 (not overwriting existing files).
22
23 OPTIONS
24 -------
25 -u|--index::
26 update stat information for the checked out entries in
27 the index file.
28
29 -q|--quiet::
30 be quiet if files exist or are not in the index
31
32 -f|--force::
33 forces overwrite of existing files
34
35 -a|--all::
36 checks out all files in the index. Cannot be used
37 together with explicit filenames.
38
39 -n|--no-create::
40 Don't checkout new files, only refresh files already checked
41 out.
42
43 --prefix=<string>::
44 When creating files, prepend <string> (usually a directory
45 including a trailing /)
46
47 --stage=<number>|all::
48 Instead of checking out unmerged entries, copy out the
49 files from named stage. <number> must be between 1 and 3.
50 Note: --stage=all automatically implies --temp.
51
52 --temp::
53 Instead of copying the files to the working directory
54 write the content to temporary files. The temporary name
55 associations will be written to stdout.
56
57 --stdin::
58 Instead of taking list of paths from the command line,
59 read list of paths from the standard input. Paths are
60 separated by LF (i.e. one path per line) by default.
61
62 -z::
63 Only meaningful with `--stdin`; paths are separated with
64 NUL character instead of LF.
65
66 \--::
67 Do not interpret any more arguments as options.
68
69 The order of the flags used to matter, but not anymore.
70
71 Just doing `git-checkout-index` does nothing. You probably meant
72 `git-checkout-index -a`. And if you want to force it, you want
73 `git-checkout-index -f -a`.
74
75 Intuitiveness is not the goal here. Repeatability is. The reason for
76 the "no arguments means no work" behavior is that from scripts you are
77 supposed to be able to do:
78
79 ----------------
80 $ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
81 ----------------
82
83 which will force all existing `*.h` files to be replaced with their
84 cached copies. If an empty command line implied "all", then this would
85 force-refresh everything in the index, which was not the point. But
86 since git-checkout-index accepts --stdin it would be faster to use:
87
88 ----------------
89 $ find . -name '*.h' -print0 | git-checkout-index -f -z --stdin
90 ----------------
91
92 The `--` is just a good idea when you know the rest will be filenames;
93 it will prevent problems with a filename of, for example, `-a`.
94 Using `--` is probably a good policy in scripts.
95
96
97 Using --temp or --stage=all
98 ---------------------------
99 When `--temp` is used (or implied by `--stage=all`)
100 `git-checkout-index` will create a temporary file for each index
101 entry being checked out. The index will not be updated with stat
102 information. These options can be useful if the caller needs all
103 stages of all unmerged entries so that the unmerged files can be
104 processed by an external merge tool.
105
106 A listing will be written to stdout providing the association of
107 temporary file names to tracked path names. The listing format
108 has two variations:
109
110 . tempname TAB path RS
111 +
112 The first format is what gets used when `--stage` is omitted or
113 is not `--stage=all`. The field tempname is the temporary file
114 name holding the file content and path is the tracked path name in
115 the index. Only the requested entries are output.
116
117 . stage1temp SP stage2temp SP stage3tmp TAB path RS
118 +
119 The second format is what gets used when `--stage=all`. The three
120 stage temporary fields (stage1temp, stage2temp, stage3temp) list the
121 name of the temporary file if there is a stage entry in the index
122 or `.` if there is no stage entry. Paths which only have a stage 0
123 entry will always be omitted from the output.
124
125 In both formats RS (the record separator) is newline by default
126 but will be the null byte if -z was passed on the command line.
127 The temporary file names are always safe strings; they will never
128 contain directory separators or whitespace characters. The path
129 field is always relative to the current directory and the temporary
130 file names are always relative to the top level directory.
131
132 If the object being copied out to a temporary file is a symbolic
133 link the content of the link will be written to a normal file. It is
134 up to the end-user or the Porcelain to make use of this information.
135
136
137 EXAMPLES
138 --------
139 To update and refresh only the files already checked out::
140 +
141 ----------------
142 $ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
143 ----------------
144
145 Using `git-checkout-index` to "export an entire tree"::
146 The prefix ability basically makes it trivial to use
147 `git-checkout-index` as an "export as tree" function.
148 Just read the desired tree into the index, and do:
149 +
150 ----------------
151 $ git-checkout-index --prefix=git-export-dir/ -a
152 ----------------
153 +
154 `git-checkout-index` will "export" the index into the specified
155 directory.
156 +
157 The final "/" is important. The exported name is literally just
158 prefixed with the specified string. Contrast this with the
159 following example.
160
161 Export files with a prefix::
162 +
163 ----------------
164 $ git-checkout-index --prefix=.merged- Makefile
165 ----------------
166 +
167 This will check out the currently cached copy of `Makefile`
168 into the file `.merged-Makefile`.
169
170
171 Author
172 ------
173 Written by Linus Torvalds <torvalds@osdl.org>
174
175
176 Documentation
177 --------------
178 Documentation by David Greaves,
179 Junio C Hamano and the git-list <git@vger.kernel.org>.
180
181
182 GIT
183 ---
184 Part of the gitlink:git[7] suite
185