2 .\" Title: git-checkout-index
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.42.0.rc0
10 .TH "GIT\-CHECKOUT\-INDEX" "1" "2023\-08\-04" "Git 2\&.42\&.0\&.rc0" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-checkout-index \- Copy files from the index to the working tree
35 \fIgit checkout\-index\fR [\-u] [\-q] [\-a] [\-f] [\-n] [\-\-prefix=<string>]
36 [\-\-stage=<number>|all]
38 [\-\-ignore\-skip\-worktree\-bits]
45 Will copy all files listed from the index to the working directory (not overwriting existing files)\&.
50 update stat information for the checked out entries in the index file\&.
55 be quiet if files exist or are not in the index
60 forces overwrite of existing files
65 checks out all files in the index except for those with the skip\-worktree bit set (see
66 \fB\-\-ignore\-skip\-worktree\-bits\fR)\&. Cannot be used together with explicit filenames\&.
71 Don\(cqt checkout new files, only refresh files already checked out\&.
76 When creating files, prepend <string> (usually a directory including a trailing /)
79 \-\-stage=<number>|all
81 Instead of checking out unmerged entries, copy out the files from named stage\&. <number> must be between 1 and 3\&. Note: \-\-stage=all automatically implies \-\-temp\&.
86 Instead of copying the files to the working directory write the content to temporary files\&. The temporary name associations will be written to stdout\&.
89 \-\-ignore\-skip\-worktree\-bits
91 Check out all files, including those with the skip\-worktree bit set\&.
96 Instead of taking list of paths from the command line, read list of paths from the standard input\&. Paths are separated by LF (i\&.e\&. one path per line) by default\&.
102 \fB\-\-stdin\fR; paths are separated with NUL character instead of LF\&.
107 Do not interpret any more arguments as options\&.
110 The order of the flags used to matter, but not anymore\&.
112 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\&.
114 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:
120 $ find \&. \-name \*(Aq*\&.h\*(Aq \-print0 | xargs \-0 git checkout\-index \-f \-\-
127 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:
133 $ find \&. \-name \*(Aq*\&.h\*(Aq \-print0 | git checkout\-index \-f \-z \-\-stdin
140 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\&.
141 .SH "USING \-\-TEMP OR \-\-STAGE=ALL"
143 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\&.
145 A listing will be written to stdout providing the association of temporary file names to tracked path names\&. The listing format has two variations:
157 The first format is what gets used when
160 \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\&.
171 stage1temp SP stage2temp SP stage3tmp TAB path RS
173 The second format is what gets used when
174 \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
176 if there is no stage entry\&. Paths which only have a stage 0 entry will always be omitted from the output\&.
179 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\&.
181 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\&.
184 To update and refresh only the files already checked out
191 $ git checkout\-index \-n \-f \-a && git update\-index \-\-ignore\-missing \-\-refresh
199 Using \fIgit checkout\-index\fR to "export an entire tree"
201 The prefix ability basically makes it trivial to use
202 \fIgit checkout\-index\fR
203 as an "export as tree" function\&. Just read the desired tree into the index, and do:
209 $ git checkout\-index \-\-prefix=git\-export\-dir/ \-a
215 \fBgit checkout\-index\fR
216 will "export" the index into the specified directory\&.
218 The final "/" is important\&. The exported name is literally just prefixed with the specified string\&. Contrast this with the following example\&.
221 Export files with a prefix
228 $ git checkout\-index \-\-prefix=\&.merged\- Makefile
234 This will check out the currently cached copy of
237 \fB\&.merged\-Makefile\fR\&.
241 Part of the \fBgit\fR(1) suite