blob: faf8d6ca36fb7c3bfd7a8e880efe284746cdc94d [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-checkout-index(1)
2=====================
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-checkout-index - Copy files from the index to the working tree
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3812'git checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
Junio C Hamanof84a2b12006-03-07 05:16:2813 [--stage=<number>|all]
14 [--temp]
Junio C Hamano034a2ff2022-02-18 00:40:1115 [--ignore-skip-worktree-bits]
Junio C Hamanodecf50e2006-03-05 10:51:1416 [-z] [--stdin]
Junio C Hamanod2179ef2010-10-22 04:12:1717 [--] [<file>...]
Junio C Hamano1a4e8412005-12-27 08:17:2318
19DESCRIPTION
20-----------
Junio C Hamano33be8212023-10-23 21:45:5421Copies all listed files from the index to the working directory
Junio C Hamano1a4e8412005-12-27 08:17:2322(not overwriting existing files).
23
24OPTIONS
25-------
Junio C Hamanoeb415992008-06-08 22:49:4726-u::
27--index::
Junio C Hamano1a4e8412005-12-27 08:17:2328update stat information for the checked out entries in
29the index file.
30
Junio C Hamanoeb415992008-06-08 22:49:4731-q::
32--quiet::
Junio C Hamano1a4e8412005-12-27 08:17:2333be quiet if files exist or are not in the index
34
Junio C Hamanoeb415992008-06-08 22:49:4735-f::
36--force::
Junio C Hamano1a4e8412005-12-27 08:17:2337forces overwrite of existing files
38
Junio C Hamanoeb415992008-06-08 22:49:4739-a::
40--all::
Junio C Hamano034a2ff2022-02-18 00:40:1141checks out all files in the index except for those with the
42skip-worktree bit set (see `--ignore-skip-worktree-bits`).
43Cannot be used together with explicit filenames.
Junio C Hamano1a4e8412005-12-27 08:17:2344
Junio C Hamanoeb415992008-06-08 22:49:4745-n::
46--no-create::
Junio C Hamano1a4e8412005-12-27 08:17:2347Don't checkout new files, only refresh files already checked
48out.
49
50--prefix=<string>::
51When creating files, prepend <string> (usually a directory
52including a trailing /)
53
Junio C Hamanof84a2b12006-03-07 05:16:2854--stage=<number>|all::
Junio C Hamano1a4e8412005-12-27 08:17:2355Instead of checking out unmerged entries, copy out the
Junio C Hamano33be8212023-10-23 21:45:5456files from the named stage. <number> must be between 1 and 3.
Junio C Hamanof84a2b12006-03-07 05:16:2857Note: --stage=all automatically implies --temp.
58
59--temp::
Junio C Hamano33be8212023-10-23 21:45:5460Instead of copying the files to the working directory,
Junio C Hamanof84a2b12006-03-07 05:16:2861write the content to temporary files. The temporary name
62associations will be written to stdout.
Junio C Hamano1a4e8412005-12-27 08:17:2363
Junio C Hamano034a2ff2022-02-18 00:40:1164--ignore-skip-worktree-bits::
65Check out all files, including those with the skip-worktree bit
66set.
67
Junio C Hamanodecf50e2006-03-05 10:51:1468--stdin::
Junio C Hamano33be8212023-10-23 21:45:5469Instead of taking a list of paths from the command line,
70read the list of paths from the standard input. Paths are
Junio C Hamanodecf50e2006-03-05 10:51:1471separated by LF (i.e. one path per line) by default.
72
73-z::
74Only meaningful with `--stdin`; paths are separated with
75NUL character instead of LF.
76
Junio C Hamano1bb569e2006-05-05 23:14:2577\--::
Junio C Hamano1a4e8412005-12-27 08:17:2378Do not interpret any more arguments as options.
79
80The order of the flags used to matter, but not anymore.
81
Junio C Hamanofce7c7e2008-07-02 03:06:3882Just doing `git checkout-index` does nothing. You probably meant
83`git checkout-index -a`. And if you want to force it, you want
84`git checkout-index -f -a`.
Junio C Hamano1a4e8412005-12-27 08:17:2385
86Intuitiveness is not the goal here. Repeatability is. The reason for
87the "no arguments means no work" behavior is that from scripts you are
88supposed to be able to do:
89
90----------------
Junio C Hamanofce7c7e2008-07-02 03:06:3891$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
Junio C Hamano1a4e8412005-12-27 08:17:2392----------------
93
94which will force all existing `*.h` files to be replaced with their
95cached copies. If an empty command line implied "all", then this would
Junio C Hamanodecf50e2006-03-05 10:51:1496force-refresh everything in the index, which was not the point. But
Junio C Hamano1aa40d22010-01-21 17:46:4397since 'git checkout-index' accepts --stdin it would be faster to use:
Junio C Hamanodecf50e2006-03-05 10:51:1498
99----------------
Junio C Hamanofce7c7e2008-07-02 03:06:38100$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
Junio C Hamanodecf50e2006-03-05 10:51:14101----------------
Junio C Hamano1a4e8412005-12-27 08:17:23102
103The `--` is just a good idea when you know the rest will be filenames;
104it will prevent problems with a filename of, for example, `-a`.
105Using `--` is probably a good policy in scripts.
106
107
Junio C Hamanof84a2b12006-03-07 05:16:28108Using --temp or --stage=all
109---------------------------
110When `--temp` is used (or implied by `--stage=all`)
Junio C Hamano1aa40d22010-01-21 17:46:43111'git checkout-index' will create a temporary file for each index
Junio C Hamanof84a2b12006-03-07 05:16:28112entry being checked out. The index will not be updated with stat
113information. These options can be useful if the caller needs all
114stages of all unmerged entries so that the unmerged files can be
115processed by an external merge tool.
116
117A listing will be written to stdout providing the association of
118temporary file names to tracked path names. The listing format
119has two variations:
120
121 . tempname TAB path RS
122+
123The first format is what gets used when `--stage` is omitted or
124is not `--stage=all`. The field tempname is the temporary file
125name holding the file content and path is the tracked path name in
126the index. Only the requested entries are output.
127
128 . stage1temp SP stage2temp SP stage3tmp TAB path RS
129+
130The second format is what gets used when `--stage=all`. The three
131stage temporary fields (stage1temp, stage2temp, stage3temp) list the
132name of the temporary file if there is a stage entry in the index
133or `.` if there is no stage entry. Paths which only have a stage 0
134entry will always be omitted from the output.
135
136In both formats RS (the record separator) is newline by default
137but will be the null byte if -z was passed on the command line.
138The temporary file names are always safe strings; they will never
139contain directory separators or whitespace characters. The path
140field is always relative to the current directory and the temporary
141file names are always relative to the top level directory.
142
143If the object being copied out to a temporary file is a symbolic
144link the content of the link will be written to a normal file. It is
145up to the end-user or the Porcelain to make use of this information.
146
147
Junio C Hamano1a4e8412005-12-27 08:17:23148EXAMPLES
149--------
150To update and refresh only the files already checked out::
151+
152----------------
Junio C Hamanofce7c7e2008-07-02 03:06:38153$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
Junio C Hamano1a4e8412005-12-27 08:17:23154----------------
155
Junio C Hamano1aa40d22010-01-21 17:46:43156Using 'git checkout-index' to "export an entire tree"::
Junio C Hamano1a4e8412005-12-27 08:17:23157The prefix ability basically makes it trivial to use
Junio C Hamano1aa40d22010-01-21 17:46:43158'git checkout-index' as an "export as tree" function.
Junio C Hamano1a4e8412005-12-27 08:17:23159Just read the desired tree into the index, and do:
160+
161----------------
Junio C Hamanofce7c7e2008-07-02 03:06:38162$ git checkout-index --prefix=git-export-dir/ -a
Junio C Hamano1a4e8412005-12-27 08:17:23163----------------
164+
Junio C Hamanofce7c7e2008-07-02 03:06:38165`git checkout-index` will "export" the index into the specified
Junio C Hamano1a4e8412005-12-27 08:17:23166directory.
167+
168The final "/" is important. The exported name is literally just
169prefixed with the specified string. Contrast this with the
170following example.
171
172Export files with a prefix::
173+
174----------------
Junio C Hamanofce7c7e2008-07-02 03:06:38175$ git checkout-index --prefix=.merged- Makefile
Junio C Hamano1a4e8412005-12-27 08:17:23176----------------
177+
178This will check out the currently cached copy of `Makefile`
179into the file `.merged-Makefile`.
180
Junio C Hamano1a4e8412005-12-27 08:17:23181GIT
182---
Junio C Hamanof7c042d2008-06-06 22:50:53183Part of the linkgit:git[1] suite