1GIT-CHECKOUT-INDEX(1) Git Manual GIT-CHECKOUT-INDEX(1)
2
3
4
6 git-checkout-index - Copy files from the index to the working tree
7
9 git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
10 [--stage=<number>|all]
11 [--temp]
12 [-z] [--stdin]
13 [--] [<file>...]
14
15
17 Will copy all files listed from the index to the working directory (not
18 overwriting existing files).
19
21 -u, --index
22 update stat information for the checked out entries in the index
23 file.
24
25 -q, --quiet
26 be quiet if files exist or are not in the index
27
28 -f, --force
29 forces overwrite of existing files
30
31 -a, --all
32 checks out all files in the index. Cannot be used together with
33 explicit filenames.
34
35 -n, --no-create
36 Don’t checkout new files, only refresh files already checked out.
37
38 --prefix=<string>
39 When creating files, prepend <string> (usually a directory
40 including a trailing /)
41
42 --stage=<number>|all
43 Instead of checking out unmerged entries, copy out the files from
44 named stage. <number> must be between 1 and 3. Note: --stage=all
45 automatically implies --temp.
46
47 --temp
48 Instead of copying the files to the working directory write the
49 content to temporary files. The temporary name associations will be
50 written to stdout.
51
52 --stdin
53 Instead of taking list of paths from the command line, read list of
54 paths from the standard input. Paths are separated by LF (i.e. one
55 path per line) by default.
56
57 -z
58 Only meaningful with --stdin; paths are separated with NUL
59 character instead of LF.
60
61 --
62 Do not interpret any more arguments as options.
63
64 The order of the flags used to matter, but not anymore.
65
66 Just doing git checkout-index does nothing. You probably meant git
67 checkout-index -a. And if you want to force it, you want git
68 checkout-index -f -a.
69
70 Intuitiveness is not the goal here. Repeatability is. The reason for
71 the "no arguments means no work" behavior is that from scripts you are
72 supposed to be able to do:
73
74 $ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
75
76
77 which will force all existing *.h files to be replaced with their
78 cached copies. If an empty command line implied "all", then this would
79 force-refresh everything in the index, which was not the point. But
80 since git checkout-index accepts --stdin it would be faster to use:
81
82 $ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
83
84
85 The -- is just a good idea when you know the rest will be filenames; it
86 will prevent problems with a filename of, for example, -a. Using -- is
87 probably a good policy in scripts.
88
90 When --temp is used (or implied by --stage=all) git checkout-index will
91 create a temporary file for each index entry being checked out. The
92 index will not be updated with stat information. These options can be
93 useful if the caller needs all stages of all unmerged entries so that
94 the unmerged files can be processed by an external merge tool.
95
96 A listing will be written to stdout providing the association of
97 temporary file names to tracked path names. The listing format has two
98 variations:
99
100 1. tempname TAB path RS
101
102 The first format is what gets used when --stage is omitted or is
103 not --stage=all. The field tempname is the temporary file name
104 holding the file content and path is the tracked path name in the
105 index. Only the requested entries are output.
106
107 2. stage1temp SP stage2temp SP stage3tmp TAB path RS
108
109 The second format is what gets used when --stage=all. The three
110 stage temporary fields (stage1temp, stage2temp, stage3temp) list
111 the name of the temporary file if there is a stage entry in the
112 index or . if there is no stage entry. Paths which only have a
113 stage 0 entry will always be omitted from the output.
114
115 In both formats RS (the record separator) is newline by default but
116 will be the null byte if -z was passed on the command line. The
117 temporary file names are always safe strings; they will never contain
118 directory separators or whitespace characters. The path field is always
119 relative to the current directory and the temporary file names are
120 always relative to the top level directory.
121
122 If the object being copied out to a temporary file is a symbolic link
123 the content of the link will be written to a normal file. It is up to
124 the end-user or the Porcelain to make use of this information.
125
127 To update and refresh only the files already checked out
128
129 $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
130
131
132 Using git checkout-index to "export an entire tree"
133 The prefix ability basically makes it trivial to use git
134 checkout-index as an "export as tree" function. Just read the
135 desired tree into the index, and do:
136
137 $ git checkout-index --prefix=git-export-dir/ -a
138
139 git checkout-index will "export" the index into the specified
140 directory.
141
142 The final "/" is important. The exported name is literally just
143 prefixed with the specified string. Contrast this with the
144 following example.
145
146 Export files with a prefix
147
148 $ git checkout-index --prefix=.merged- Makefile
149
150 This will check out the currently cached copy of Makefile into the
151 file .merged-Makefile.
152
154 Part of the git(1) suite
155
156
157
158Git 2.20.1 12/15/2018 GIT-CHECKOUT-INDEX(1)