updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-checkout-index.xml
blob1359cd1fcb50ec0b4a74e7dca06fc805e930d671
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-checkout-index(1)">\r
5 <articleinfo>\r
6     <title>git-checkout-index(1)</title>\r
7 <indexterm>\r
8 <primary>git-checkout-index(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-checkout-index - Copy files from the index to the working tree</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git checkout-index</emphasis> [-u] [-q] [-a] [-f] [-n] [--prefix=&lt;string&gt;]\r
19                    [--stage=&lt;number&gt;|all]\r
20                    [--temp]\r
21                    [-z] [--stdin]\r
22                    [--] [&lt;file&gt;&#8230;]</literallayout>\r
23 </blockquote>\r
24 </simplesect>\r
25 <simplesect id="_description">\r
26 <title>DESCRIPTION</title>\r
27 <simpara>Will copy all files listed from the index to the working directory\r
28 (not overwriting existing files).</simpara>\r
29 </simplesect>\r
30 <simplesect id="_options">\r
31 <title>OPTIONS</title>\r
32 <variablelist>\r
33 <varlistentry>\r
34 <term>\r
35 -u\r
36 </term>\r
37 <term>\r
38 --index\r
39 </term>\r
40 <listitem>\r
41 <simpara>\r
42         update stat information for the checked out entries in\r
43         the index file.\r
44 </simpara>\r
45 </listitem>\r
46 </varlistentry>\r
47 <varlistentry>\r
48 <term>\r
49 -q\r
50 </term>\r
51 <term>\r
52 --quiet\r
53 </term>\r
54 <listitem>\r
55 <simpara>\r
56         be quiet if files exist or are not in the index\r
57 </simpara>\r
58 </listitem>\r
59 </varlistentry>\r
60 <varlistentry>\r
61 <term>\r
62 -f\r
63 </term>\r
64 <term>\r
65 --force\r
66 </term>\r
67 <listitem>\r
68 <simpara>\r
69         forces overwrite of existing files\r
70 </simpara>\r
71 </listitem>\r
72 </varlistentry>\r
73 <varlistentry>\r
74 <term>\r
75 -a\r
76 </term>\r
77 <term>\r
78 --all\r
79 </term>\r
80 <listitem>\r
81 <simpara>\r
82         checks out all files in the index.  Cannot be used\r
83         together with explicit filenames.\r
84 </simpara>\r
85 </listitem>\r
86 </varlistentry>\r
87 <varlistentry>\r
88 <term>\r
89 -n\r
90 </term>\r
91 <term>\r
92 --no-create\r
93 </term>\r
94 <listitem>\r
95 <simpara>\r
96         Don't checkout new files, only refresh files already checked\r
97         out.\r
98 </simpara>\r
99 </listitem>\r
100 </varlistentry>\r
101 <varlistentry>\r
102 <term>\r
103 --prefix=&lt;string&gt;\r
104 </term>\r
105 <listitem>\r
106 <simpara>\r
107         When creating files, prepend &lt;string&gt; (usually a directory\r
108         including a trailing /)\r
109 </simpara>\r
110 </listitem>\r
111 </varlistentry>\r
112 <varlistentry>\r
113 <term>\r
114 --stage=&lt;number&gt;|all\r
115 </term>\r
116 <listitem>\r
117 <simpara>\r
118         Instead of checking out unmerged entries, copy out the\r
119         files from named stage.  &lt;number&gt; must be between 1 and 3.\r
120         Note: --stage=all automatically implies --temp.\r
121 </simpara>\r
122 </listitem>\r
123 </varlistentry>\r
124 <varlistentry>\r
125 <term>\r
126 --temp\r
127 </term>\r
128 <listitem>\r
129 <simpara>\r
130         Instead of copying the files to the working directory\r
131         write the content to temporary files.  The temporary name\r
132         associations will be written to stdout.\r
133 </simpara>\r
134 </listitem>\r
135 </varlistentry>\r
136 <varlistentry>\r
137 <term>\r
138 --stdin\r
139 </term>\r
140 <listitem>\r
141 <simpara>\r
142         Instead of taking list of paths from the command line,\r
143         read list of paths from the standard input.  Paths are\r
144         separated by LF (i.e. one path per line) by default.\r
145 </simpara>\r
146 </listitem>\r
147 </varlistentry>\r
148 <varlistentry>\r
149 <term>\r
150 -z\r
151 </term>\r
152 <listitem>\r
153 <simpara>\r
154         Only meaningful with <emphasis>--stdin</emphasis>; paths are separated with\r
155         NUL character instead of LF.\r
156 </simpara>\r
157 </listitem>\r
158 </varlistentry>\r
159 <varlistentry>\r
160 <term>\r
161 --\r
162 </term>\r
163 <listitem>\r
164 <simpara>\r
165         Do not interpret any more arguments as options.\r
166 </simpara>\r
167 </listitem>\r
168 </varlistentry>\r
169 </variablelist>\r
170 <simpara>The order of the flags used to matter, but not anymore.</simpara>\r
171 <simpara>Just doing <emphasis>git checkout-index</emphasis> does nothing. You probably meant\r
172 <emphasis>git checkout-index -a</emphasis>. And if you want to force it, you want\r
173 <emphasis>git checkout-index -f -a</emphasis>.</simpara>\r
174 <simpara>Intuitiveness is not the goal here. Repeatability is. The reason for\r
175 the "no arguments means no work" behavior is that from scripts you are\r
176 supposed to be able to do:</simpara>\r
177 <screen>$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --</screen>\r
178 <simpara>which will force all existing <emphasis>*.h</emphasis> files to be replaced with their\r
179 cached copies. If an empty command line implied "all", then this would\r
180 force-refresh everything in the index, which was not the point.  But\r
181 since <emphasis>git checkout-index</emphasis> accepts --stdin it would be faster to use:</simpara>\r
182 <screen>$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin</screen>\r
183 <simpara>The <emphasis>--</emphasis> is just a good idea when you know the rest will be filenames;\r
184 it will prevent problems with a filename of, for example,  <emphasis>-a</emphasis>.\r
185 Using <emphasis>--</emphasis> is probably a good policy in scripts.</simpara>\r
186 </simplesect>\r
187 <simplesect id="_using_temp_or_stage_all">\r
188 <title>Using --temp or --stage=all</title>\r
189 <simpara>When <emphasis>--temp</emphasis> is used (or implied by <emphasis>--stage=all</emphasis>)\r
190 <emphasis>git checkout-index</emphasis> will create a temporary file for each index\r
191 entry being checked out.  The index will not be updated with stat\r
192 information.  These options can be useful if the caller needs all\r
193 stages of all unmerged entries so that the unmerged files can be\r
194 processed by an external merge tool.</simpara>\r
195 <simpara>A listing will be written to stdout providing the association of\r
196 temporary file names to tracked path names.  The listing format\r
197 has two variations:</simpara>\r
198 <orderedlist numeration="arabic">\r
199 <listitem>\r
200 <simpara>\r
201 tempname TAB path RS\r
202 </simpara>\r
203 <simpara>The first format is what gets used when <emphasis>--stage</emphasis> is omitted or\r
204 is not <emphasis>--stage=all</emphasis>. The field tempname is the temporary file\r
205 name holding the file content and path is the tracked path name in\r
206 the index.  Only the requested entries are output.</simpara>\r
207 </listitem>\r
208 <listitem>\r
209 <simpara>\r
210 stage1temp SP stage2temp SP stage3tmp TAB path RS\r
211 </simpara>\r
212 <simpara>The second format is what gets used when <emphasis>--stage=all</emphasis>.  The three\r
213 stage temporary fields (stage1temp, stage2temp, stage3temp) list the\r
214 name of the temporary file if there is a stage entry in the index\r
215 or <emphasis>.</emphasis> if there is no stage entry.  Paths which only have a stage 0\r
216 entry will always be omitted from the output.</simpara>\r
217 </listitem>\r
218 </orderedlist>\r
219 <simpara>In both formats RS (the record separator) is newline by default\r
220 but will be the null byte if -z was passed on the command line.\r
221 The temporary file names are always safe strings; they will never\r
222 contain directory separators or whitespace characters.  The path\r
223 field is always relative to the current directory and the temporary\r
224 file names are always relative to the top level directory.</simpara>\r
225 <simpara>If the object being copied out to a temporary file is a symbolic\r
226 link the content of the link will be written to a normal file.  It is\r
227 up to the end-user or the Porcelain to make use of this information.</simpara>\r
228 </simplesect>\r
229 <simplesect id="_examples">\r
230 <title>EXAMPLES</title>\r
231 <variablelist>\r
232 <varlistentry>\r
233 <term>\r
234 To update and refresh only the files already checked out\r
235 </term>\r
236 <listitem>\r
237 <screen>$ git checkout-index -n -f -a &amp;&amp; git update-index --ignore-missing --refresh</screen>\r
238 </listitem>\r
239 </varlistentry>\r
240 <varlistentry>\r
241 <term>\r
242 Using <emphasis>git checkout-index</emphasis> to "export an entire tree"\r
243 </term>\r
244 <listitem>\r
245 <simpara>\r
246         The prefix ability basically makes it trivial to use\r
247         <emphasis>git checkout-index</emphasis> as an "export as tree" function.\r
248         Just read the desired tree into the index, and do:\r
249 </simpara>\r
250 <screen>$ git checkout-index --prefix=git-export-dir/ -a</screen>\r
251 <simpara><emphasis>git checkout-index</emphasis> will "export" the index into the specified\r
252 directory.</simpara>\r
253 <simpara>The final "/" is important. The exported name is literally just\r
254 prefixed with the specified string.  Contrast this with the\r
255 following example.</simpara>\r
256 </listitem>\r
257 </varlistentry>\r
258 <varlistentry>\r
259 <term>\r
260 Export files with a prefix\r
261 </term>\r
262 <listitem>\r
263 <screen>$ git checkout-index --prefix=.merged- Makefile</screen>\r
264 <simpara>This will check out the currently cached copy of <emphasis>Makefile</emphasis>\r
265 into the file <emphasis>.merged-Makefile</emphasis>.</simpara>\r
266 </listitem>\r
267 </varlistentry>\r
268 </variablelist>\r
269 </simplesect>\r
270 <simplesect id="_git">\r
271 <title>GIT</title>\r
272 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
273 </simplesect>\r
274 </article>\r