1GIT-CHECKOUT-INDEX(1)             Git Manual             GIT-CHECKOUT-INDEX(1)
2
3
4

NAME

6       git-checkout-index - Copy files from the index to the working tree
7

SYNOPSIS

9       git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
10                          [--stage=<number>|all]
11                          [--temp]
12                          [-z] [--stdin]
13                          [--] [<file>...]
14

DESCRIPTION

16       Will copy all files listed from the index to the working directory (not
17       overwriting existing files).
18

OPTIONS

20       -u, --index
21           update stat information for the checked out entries in the index
22           file.
23
24       -q, --quiet
25           be quiet if files exist or are not in the index
26
27       -f, --force
28           forces overwrite of existing files
29
30       -a, --all
31           checks out all files in the index. Cannot be used together with
32           explicit filenames.
33
34       -n, --no-create
35           Don’t checkout new files, only refresh files already checked out.
36
37       --prefix=<string>
38           When creating files, prepend <string> (usually a directory
39           including a trailing /)
40
41       --stage=<number>|all
42           Instead of checking out unmerged entries, copy out the files from
43           named stage. <number> must be between 1 and 3. Note: --stage=all
44           automatically implies --temp.
45
46       --temp
47           Instead of copying the files to the working directory write the
48           content to temporary files. The temporary name associations will be
49           written to stdout.
50
51       --stdin
52           Instead of taking list of paths from the command line, read list of
53           paths from the standard input. Paths are separated by LF (i.e. one
54           path per line) by default.
55
56       -z
57           Only meaningful with --stdin; paths are separated with NUL
58           character instead of LF.
59
60       --
61           Do not interpret any more arguments as options.
62
63       The order of the flags used to matter, but not anymore.
64
65       Just doing git checkout-index does nothing. You probably meant git
66       checkout-index -a. And if you want to force it, you want git
67       checkout-index -f -a.
68
69       Intuitiveness is not the goal here. Repeatability is. The reason for
70       the "no arguments means no work" behavior is that from scripts you are
71       supposed to be able to do:
72
73           $ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
74
75       which will force all existing *.h files to be replaced with their
76       cached copies. If an empty command line implied "all", then this would
77       force-refresh everything in the index, which was not the point. But
78       since git checkout-index accepts --stdin it would be faster to use:
79
80           $ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
81
82       The -- is just a good idea when you know the rest will be filenames; it
83       will prevent problems with a filename of, for example, -a. Using -- is
84       probably a good policy in scripts.
85

USING --TEMP OR --STAGE=ALL

87       When --temp is used (or implied by --stage=all) git checkout-index will
88       create a temporary file for each index entry being checked out. The
89       index will not be updated with stat information. These options can be
90       useful if the caller needs all stages of all unmerged entries so that
91       the unmerged files can be processed by an external merge tool.
92
93       A listing will be written to stdout providing the association of
94       temporary file names to tracked path names. The listing format has two
95       variations:
96
97        1. tempname TAB path RS
98
99           The first format is what gets used when --stage is omitted or is
100           not --stage=all. The field tempname is the temporary file name
101           holding the file content and path is the tracked path name in the
102           index. Only the requested entries are output.
103
104        2. stage1temp SP stage2temp SP stage3tmp TAB path RS
105
106           The second format is what gets used when --stage=all. The three
107           stage temporary fields (stage1temp, stage2temp, stage3temp) list
108           the name of the temporary file if there is a stage entry in the
109           index or .  if there is no stage entry. Paths which only have a
110           stage 0 entry will always be omitted from the output.
111
112       In both formats RS (the record separator) is newline by default but
113       will be the null byte if -z was passed on the command line. The
114       temporary file names are always safe strings; they will never contain
115       directory separators or whitespace characters. The path field is always
116       relative to the current directory and the temporary file names are
117       always relative to the top level directory.
118
119       If the object being copied out to a temporary file is a symbolic link
120       the content of the link will be written to a normal file. It is up to
121       the end-user or the Porcelain to make use of this information.
122

EXAMPLES

124       To update and refresh only the files already checked out
125
126               $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
127
128       Using git checkout-index to "export an entire tree"
129           The prefix ability basically makes it trivial to use git
130           checkout-index as an "export as tree" function. Just read the
131           desired tree into the index, and do:
132
133               $ git checkout-index --prefix=git-export-dir/ -a
134
135           git checkout-index will "export" the index into the specified
136           directory.
137
138           The final "/" is important. The exported name is literally just
139           prefixed with the specified string. Contrast this with the
140           following example.
141
142       Export files with a prefix
143
144               $ git checkout-index --prefix=.merged- Makefile
145
146           This will check out the currently cached copy of Makefile into the
147           file .merged-Makefile.
148

GIT

150       Part of the git(1) suite
151
152
153
154Git 2.30.2                        2021-03-08             GIT-CHECKOUT-INDEX(1)
Impressum