summaryrefslogtreecommitdiffstats
path: root/man1/git-checkout-index.1
blob: 9e1c6d5a6b5f9cf3bfe519d2885057c21b77dd29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
'\" t
.\"     Title: git-checkout-index
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2024-04-15
.\"    Manual: Git Manual
.\"    Source: Git 2.44.0.616.g548fe35913
.\"  Language: English
.\"
.TH "GIT\-CHECKOUT\-INDEX" "1" "2024\-04\-15" "Git 2\&.44\&.0\&.616\&.g548fe3" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-checkout-index \- Copy files from the index to the working tree
.SH "SYNOPSIS"
.sp
.nf
\fIgit checkout\-index\fR [\-u] [\-q] [\-a] [\-f] [\-n] [\-\-prefix=<string>]
                   [\-\-stage=<number>|all]
                   [\-\-temp]
                   [\-\-ignore\-skip\-worktree\-bits]
                   [\-z] [\-\-stdin]
                   [\-\-] [<file>\&...]
.fi
.sp
.SH "DESCRIPTION"
.sp
Copies all listed files from the index to the working directory (not overwriting existing files)\&.
.SH "OPTIONS"
.PP
\-u, \-\-index
.RS 4
update stat information for the checked out entries in the index file\&.
.RE
.PP
\-q, \-\-quiet
.RS 4
be quiet if files exist or are not in the index
.RE
.PP
\-f, \-\-force
.RS 4
forces overwrite of existing files
.RE
.PP
\-a, \-\-all
.RS 4
checks out all files in the index except for those with the skip\-worktree bit set (see
\fB\-\-ignore\-skip\-worktree\-bits\fR)\&. Cannot be used together with explicit filenames\&.
.RE
.PP
\-n, \-\-no\-create
.RS 4
Don\(cqt checkout new files, only refresh files already checked out\&.
.RE
.PP
\-\-prefix=<string>
.RS 4
When creating files, prepend <string> (usually a directory including a trailing /)
.RE
.PP
\-\-stage=<number>|all
.RS 4
Instead of checking out unmerged entries, copy out the files from the named stage\&. <number> must be between 1 and 3\&. Note: \-\-stage=all automatically implies \-\-temp\&.
.RE
.PP
\-\-temp
.RS 4
Instead of copying the files to the working directory, write the content to temporary files\&. The temporary name associations will be written to stdout\&.
.RE
.PP
\-\-ignore\-skip\-worktree\-bits
.RS 4
Check out all files, including those with the skip\-worktree bit set\&.
.RE
.PP
\-\-stdin
.RS 4
Instead of taking a list of paths from the command line, read the list of paths from the standard input\&. Paths are separated by LF (i\&.e\&. one path per line) by default\&.
.RE
.PP
\-z
.RS 4
Only meaningful with
\fB\-\-stdin\fR; paths are separated with NUL character instead of LF\&.
.RE
.PP
\-\-
.RS 4
Do not interpret any more arguments as options\&.
.RE
.sp
The order of the flags used to matter, but not anymore\&.
.sp
Just doing \fBgit checkout\-index\fR does nothing\&. You probably meant \fBgit checkout\-index \-a\fR\&. And if you want to force it, you want \fBgit checkout\-index \-f \-a\fR\&.
.sp
Intuitiveness is not the goal here\&. Repeatability is\&. The reason for the "no arguments means no work" behavior is that from scripts you are supposed to be able to do:
.sp
.if n \{\
.RS 4
.\}
.nf
$ find \&. \-name \*(Aq*\&.h\*(Aq \-print0 | xargs \-0 git checkout\-index \-f \-\-
.fi
.if n \{\
.RE
.\}
.sp
.sp
which will force all existing \fB*\&.h\fR files to be replaced with their cached copies\&. If an empty command line implied "all", then this would force\-refresh everything in the index, which was not the point\&. But since \fIgit checkout\-index\fR accepts \-\-stdin it would be faster to use:
.sp
.if n \{\
.RS 4
.\}
.nf
$ find \&. \-name \*(Aq*\&.h\*(Aq \-print0 | git checkout\-index \-f \-z \-\-stdin
.fi
.if n \{\
.RE
.\}
.sp
.sp
The \fB\-\-\fR is just a good idea when you know the rest will be filenames; it will prevent problems with a filename of, for example, \fB\-a\fR\&. Using \fB\-\-\fR is probably a good policy in scripts\&.
.SH "USING \-\-TEMP OR \-\-STAGE=ALL"
.sp
When \fB\-\-temp\fR is used (or implied by \fB\-\-stage=all\fR) \fIgit checkout\-index\fR will create a temporary file for each index entry being checked out\&. The index will not be updated with stat information\&. These options can be useful if the caller needs all stages of all unmerged entries so that the unmerged files can be processed by an external merge tool\&.
.sp
A listing will be written to stdout providing the association of temporary file names to tracked path names\&. The listing format has two variations:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  1." 4.2
.\}
tempname TAB path RS
.sp
The first format is what gets used when
\fB\-\-stage\fR
is omitted or is not
\fB\-\-stage=all\fR\&. The field tempname is the temporary file name holding the file content and path is the tracked path name in the index\&. Only the requested entries are output\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  2." 4.2
.\}
stage1temp SP stage2temp SP stage3tmp TAB path RS
.sp
The second format is what gets used when
\fB\-\-stage=all\fR\&. The three stage temporary fields (stage1temp, stage2temp, stage3temp) list the name of the temporary file if there is a stage entry in the index or
\fB\&.\fR
if there is no stage entry\&. Paths which only have a stage 0 entry will always be omitted from the output\&.
.RE
.sp
In both formats RS (the record separator) is newline by default but will be the null byte if \-z was passed on the command line\&. The temporary file names are always safe strings; they will never contain directory separators or whitespace characters\&. The path field is always relative to the current directory and the temporary file names are always relative to the top level directory\&.
.sp
If the object being copied out to a temporary file is a symbolic link the content of the link will be written to a normal file\&. It is up to the end\-user or the Porcelain to make use of this information\&.
.SH "EXAMPLES"
.PP
To update and refresh only the files already checked out
.RS 4
.sp
.if n \{\
.RS 4
.\}
.nf
$ git checkout\-index \-n \-f \-a && git update\-index \-\-ignore\-missing \-\-refresh
.fi
.if n \{\
.RE
.\}
.sp
.RE
.PP
Using \fIgit checkout\-index\fR to "export an entire tree"
.RS 4
The prefix ability basically makes it trivial to use
\fIgit checkout\-index\fR
as an "export as tree" function\&. Just read the desired tree into the index, and do:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git checkout\-index \-\-prefix=git\-export\-dir/ \-a
.fi
.if n \{\
.RE
.\}
.sp
\fBgit checkout\-index\fR
will "export" the index into the specified directory\&.
.sp
The final "/" is important\&. The exported name is literally just prefixed with the specified string\&. Contrast this with the following example\&.
.RE
.PP
Export files with a prefix
.RS 4
.sp
.if n \{\
.RS 4
.\}
.nf
$ git checkout\-index \-\-prefix=\&.merged\- Makefile
.fi
.if n \{\
.RE
.\}
.sp
This will check out the currently cached copy of
\fBMakefile\fR
into the file
\fB\&.merged\-Makefile\fR\&.
.RE
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite