]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-checkout-index.txt
documentation: move git(7) to git(1)
[thirdparty/git.git] / Documentation / git-checkout-index.txt
CommitLineData
215a7ad1 1git-checkout-index(1)
2cf565c5 2=====================
2cf565c5
DG
3
4NAME
5----
c3f0baac 6git-checkout-index - Copy files from the index to the working tree
2cf565c5
DG
7
8
9SYNOPSIS
10--------
353ce815 11[verse]
215a7ad1 12'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
de84f99c
SP
13 [--stage=<number>|all]
14 [--temp]
9debe63d
SP
15 [-z] [--stdin]
16 [--] [<file>]\*
2cf565c5
DG
17
18DESCRIPTION
19-----------
5f3aa197 20Will copy all files listed from the index to the working directory
2cf565c5
DG
21(not overwriting existing files).
22
23OPTIONS
24-------
2db0bfbc 25-u|--index::
415e96c8 26 update stat information for the checked out entries in
5f3aa197 27 the index file.
415e96c8 28
2db0bfbc 29-q|--quiet::
5f3aa197 30 be quiet if files exist or are not in the index
2cf565c5 31
2db0bfbc 32-f|--force::
2cf565c5
DG
33 forces overwrite of existing files
34
2db0bfbc 35-a|--all::
5f3aa197 36 checks out all files in the index. Cannot be used
fd25c82a 37 together with explicit filenames.
2cf565c5 38
2db0bfbc 39-n|--no-create::
2cf565c5
DG
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
de84f99c 47--stage=<number>|all::
3bd348ae
JH
48 Instead of checking out unmerged entries, copy out the
49 files from named stage. <number> must be between 1 and 3.
de84f99c
SP
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.
3bd348ae 56
9debe63d
SP
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
e994004f 66\--::
2cf565c5
DG
67 Do not interpret any more arguments as options.
68
fd25c82a 69The order of the flags used to matter, but not anymore.
2cf565c5 70
61f693bd
JL
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`.
2cf565c5
DG
74
75Intuitiveness is not the goal here. Repeatability is. The reason for
61f693bd
JL
76the "no arguments means no work" behavior is that from scripts you are
77supposed to be able to do:
2cf565c5 78
61f693bd
JL
79----------------
80$ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
81----------------
2cf565c5
DG
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
9debe63d
SP
85force-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----------------
2cf565c5 91
61f693bd
JL
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.
2cf565c5 95
2cf565c5 96
de84f99c
SP
97Using --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
61f693bd
JL
137EXAMPLES
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"::
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
2cf565c5 155directory.
61f693bd
JL
156+
157The final "/" is important. The exported name is literally just
158prefixed with the specified string. Contrast this with the
159following example.
fd25c82a 160
61f693bd
JL
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`.
2cf565c5 169
2cf565c5
DG
170
171Author
172------
173Written by Linus Torvalds <torvalds@osdl.org>
174
61f693bd 175
2cf565c5
DG
176Documentation
177--------------
61f693bd
JL
178Documentation by David Greaves,
179Junio C Hamano and the git-list <git@vger.kernel.org>.
180
2cf565c5
DG
181
182GIT
183---
9e1f0a85 184Part of the linkgit:git[1] suite