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
4 <article lang="en" id="git-checkout-index(1)">
\r
6 <title>git-checkout-index(1)</title>
\r
8 <primary>git-checkout-index(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-checkout-index - Copy files from the index to the working tree</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git checkout-index</emphasis> [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
\r
19 [--stage=<number>|all]
\r
22 [--] [<file>…]</literallayout>
\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
30 <simplesect id="_options">
\r
31 <title>OPTIONS</title>
\r
42 update stat information for the checked out entries in
\r
56 be quiet if files exist or are not in the index
\r
69 forces overwrite of existing files
\r
82 checks out all files in the index. Cannot be used
\r
83 together with explicit filenames.
\r
96 Don't checkout new files, only refresh files already checked
\r
103 --prefix=<string>
\r
107 When creating files, prepend <string> (usually a directory
\r
108 including a trailing /)
\r
114 --stage=<number>|all
\r
118 Instead of checking out unmerged entries, copy out the
\r
119 files from named stage. <number> must be between 1 and 3.
\r
120 Note: --stage=all automatically implies --temp.
\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
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
154 Only meaningful with <emphasis>--stdin</emphasis>; paths are separated with
\r
155 NUL character instead of LF.
\r
165 Do not interpret any more arguments as options.
\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
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
201 tempname TAB path RS
\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
210 stage1temp SP stage2temp SP stage3tmp TAB path RS
\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
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
229 <simplesect id="_examples">
\r
230 <title>EXAMPLES</title>
\r
234 To update and refresh only the files already checked out
\r
237 <screen>$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh</screen>
\r
242 Using <emphasis>git checkout-index</emphasis> to "export an entire tree"
\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
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
260 Export files with a prefix
\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
270 <simplesect id="_git">
\r
272 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r