blob: faf8d6ca36fb7c3bfd7a8e880efe284746cdc94d [file] [log] [blame]
Junio C Hamano215a7ad2005-09-07 17:26:23 -07001git-checkout-index(1)
David Greaves2cf565c2005-05-10 22:32:30 +01002=====================
David Greaves2cf565c2005-05-10 22:32:30 +01003
4NAME
5----
Junio C Hamanoc3f0baa2007-01-18 15:53:37 -08006git-checkout-index - Copy files from the index to the working tree
David Greaves2cf565c2005-05-10 22:32:30 +01007
8
9SYNOPSIS
10--------
Jonas Fonseca353ce812005-12-31 18:37:15 +010011[verse]
Jonathan Niederb1889c32008-06-30 01:09:04 -050012'git checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
Shawn Pearcede84f992006-03-05 03:24:15 -050013 [--stage=<number>|all]
14 [--temp]
Victoria Dye88078f52022-01-11 18:05:02 +000015 [--ignore-skip-worktree-bits]
Shawn Pearce9debe632006-02-28 21:43:33 -050016 [-z] [--stdin]
Štěpán Němec0adda932010-10-08 19:31:17 +020017 [--] [<file>...]
David Greaves2cf565c2005-05-10 22:32:30 +010018
19DESCRIPTION
20-----------
Elijah Newrencf6cac22023-10-08 06:45:03 +000021Copies all listed files from the index to the working directory
David Greaves2cf565c2005-05-10 22:32:30 +010022(not overwriting existing files).
23
24OPTIONS
25-------
Stephan Beyer32402402008-06-08 03:36:09 +020026-u::
27--index::
Junio C Hamano415e96c2005-05-15 14:23:12 -070028 update stat information for the checked out entries in
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010029 the index file.
Junio C Hamano415e96c2005-05-15 14:23:12 -070030
Stephan Beyer32402402008-06-08 03:36:09 +020031-q::
32--quiet::
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010033 be quiet if files exist or are not in the index
David Greaves2cf565c2005-05-10 22:32:30 +010034
Stephan Beyer32402402008-06-08 03:36:09 +020035-f::
36--force::
David Greaves2cf565c2005-05-10 22:32:30 +010037 forces overwrite of existing files
38
Stephan Beyer32402402008-06-08 03:36:09 +020039-a::
40--all::
Victoria Dye88078f52022-01-11 18:05:02 +000041 checks out all files in the index except for those with the
42 skip-worktree bit set (see `--ignore-skip-worktree-bits`).
43 Cannot be used together with explicit filenames.
David Greaves2cf565c2005-05-10 22:32:30 +010044
Stephan Beyer32402402008-06-08 03:36:09 +020045-n::
46--no-create::
David Greaves2cf565c2005-05-10 22:32:30 +010047 Don't checkout new files, only refresh files already checked
48 out.
49
50--prefix=<string>::
51 When creating files, prepend <string> (usually a directory
52 including a trailing /)
53
Shawn Pearcede84f992006-03-05 03:24:15 -050054--stage=<number>|all::
Junio C Hamano3bd348a2005-12-07 00:29:51 -080055 Instead of checking out unmerged entries, copy out the
Elijah Newren0a4f0512023-10-08 06:45:17 +000056 files from the named stage. <number> must be between 1 and 3.
Shawn Pearcede84f992006-03-05 03:24:15 -050057 Note: --stage=all automatically implies --temp.
58
59--temp::
Elijah Newren4d542682023-10-08 06:45:24 +000060 Instead of copying the files to the working directory,
Shawn Pearcede84f992006-03-05 03:24:15 -050061 write the content to temporary files. The temporary name
62 associations will be written to stdout.
Junio C Hamano3bd348a2005-12-07 00:29:51 -080063
Victoria Dye88078f52022-01-11 18:05:02 +000064--ignore-skip-worktree-bits::
65 Check out all files, including those with the skip-worktree bit
66 set.
67
Shawn Pearce9debe632006-02-28 21:43:33 -050068--stdin::
Elijah Newren0a4f0512023-10-08 06:45:17 +000069 Instead of taking a list of paths from the command line,
70 read the list of paths from the standard input. Paths are
Shawn Pearce9debe632006-02-28 21:43:33 -050071 separated by LF (i.e. one path per line) by default.
72
73-z::
74 Only meaningful with `--stdin`; paths are separated with
75 NUL character instead of LF.
76
seane9940042006-05-05 15:05:24 -040077\--::
David Greaves2cf565c2005-05-10 22:32:30 +010078 Do not interpret any more arguments as options.
79
Junio C Hamanofd25c822005-10-17 17:38:09 -070080The order of the flags used to matter, but not anymore.
David Greaves2cf565c2005-05-10 22:32:30 +010081
Jonathan Niederb1889c32008-06-30 01:09:04 -050082Just 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`.
David Greaves2cf565c2005-05-10 22:32:30 +010085
86Intuitiveness is not the goal here. Repeatability is. The reason for
Jon Loeliger61f693b2005-12-05 23:13:03 -060087the "no arguments means no work" behavior is that from scripts you are
88supposed to be able to do:
David Greaves2cf565c2005-05-10 22:32:30 +010089
Jon Loeliger61f693b2005-12-05 23:13:03 -060090----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -050091$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
Jon Loeliger61f693b2005-12-05 23:13:03 -060092----------------
David Greaves2cf565c2005-05-10 22:32:30 +010093
94which will force all existing `*.h` files to be replaced with their
95cached copies. If an empty command line implied "all", then this would
Shawn Pearce9debe632006-02-28 21:43:33 -050096force-refresh everything in the index, which was not the point. But
Thomas Rast0b444cd2010-01-10 00:33:00 +010097since 'git checkout-index' accepts --stdin it would be faster to use:
Shawn Pearce9debe632006-02-28 21:43:33 -050098
99----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500100$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
Shawn Pearce9debe632006-02-28 21:43:33 -0500101----------------
David Greaves2cf565c2005-05-10 22:32:30 +0100102
Jon Loeliger61f693b2005-12-05 23:13:03 -0600103The `--` 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.
David Greaves2cf565c2005-05-10 22:32:30 +0100106
David Greaves2cf565c2005-05-10 22:32:30 +0100107
Shawn Pearcede84f992006-03-05 03:24:15 -0500108Using --temp or --stage=all
109---------------------------
110When `--temp` is used (or implied by `--stage=all`)
Thomas Rast0b444cd2010-01-10 00:33:00 +0100111'git checkout-index' will create a temporary file for each index
Shawn Pearcede84f992006-03-05 03:24:15 -0500112entry 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
Jon Loeliger61f693b2005-12-05 23:13:03 -0600148EXAMPLES
149--------
150To update and refresh only the files already checked out::
151+
152----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500153$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
Jon Loeliger61f693b2005-12-05 23:13:03 -0600154----------------
David Greaves2cf565c2005-05-10 22:32:30 +0100155
Thomas Rast0b444cd2010-01-10 00:33:00 +0100156Using 'git checkout-index' to "export an entire tree"::
Jon Loeliger61f693b2005-12-05 23:13:03 -0600157 The prefix ability basically makes it trivial to use
Thomas Rast0b444cd2010-01-10 00:33:00 +0100158 'git checkout-index' as an "export as tree" function.
Jon Loeliger61f693b2005-12-05 23:13:03 -0600159 Just read the desired tree into the index, and do:
160+
161----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500162$ git checkout-index --prefix=git-export-dir/ -a
Jon Loeliger61f693b2005-12-05 23:13:03 -0600163----------------
164+
Jonathan Niederb1889c32008-06-30 01:09:04 -0500165`git checkout-index` will "export" the index into the specified
David Greaves2cf565c2005-05-10 22:32:30 +0100166directory.
Jon Loeliger61f693b2005-12-05 23:13:03 -0600167+
168The final "/" is important. The exported name is literally just
169prefixed with the specified string. Contrast this with the
170following example.
Junio C Hamanofd25c822005-10-17 17:38:09 -0700171
Jon Loeliger61f693b2005-12-05 23:13:03 -0600172Export files with a prefix::
173+
174----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500175$ git checkout-index --prefix=.merged- Makefile
Jon Loeliger61f693b2005-12-05 23:13:03 -0600176----------------
177+
178This will check out the currently cached copy of `Makefile`
179into the file `.merged-Makefile`.
David Greaves2cf565c2005-05-10 22:32:30 +0100180
David Greaves2cf565c2005-05-10 22:32:30 +0100181GIT
182---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200183Part of the linkgit:git[1] suite