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                          [--ignore-skip-worktree-bits]
13                          [-z] [--stdin]
14                          [--] [<file>...]
15

DESCRIPTION

17       Copies all listed files from the index to the working directory (not
18       overwriting existing files).
19

OPTIONS

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

USING --TEMP OR --STAGE=ALL

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

EXAMPLES

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

GIT

156       Part of the git(1) suite
157
158
159
160Git 2.43.0                        11/20/2023             GIT-CHECKOUT-INDEX(1)
Impressum