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