blob: 4d33e7be0f5599cc3bb74a45cb0d20fcde1631e8 [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]
Shawn Pearce9debe632006-02-28 21:43:33 -050015 [-z] [--stdin]
Štěpán Němec0adda932010-10-08 19:31:17 +020016 [--] [<file>...]
David Greaves2cf565c2005-05-10 22:32:30 +010017
18DESCRIPTION
19-----------
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010020Will copy all files listed from the index to the working directory
David Greaves2cf565c2005-05-10 22:32:30 +010021(not overwriting existing files).
22
23OPTIONS
24-------
Stephan Beyer32402402008-06-08 03:36:09 +020025-u::
26--index::
Junio C Hamano415e96c2005-05-15 14:23:12 -070027 update stat information for the checked out entries in
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010028 the index file.
Junio C Hamano415e96c2005-05-15 14:23:12 -070029
Stephan Beyer32402402008-06-08 03:36:09 +020030-q::
31--quiet::
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010032 be quiet if files exist or are not in the index
David Greaves2cf565c2005-05-10 22:32:30 +010033
Stephan Beyer32402402008-06-08 03:36:09 +020034-f::
35--force::
David Greaves2cf565c2005-05-10 22:32:30 +010036 forces overwrite of existing files
37
Stephan Beyer32402402008-06-08 03:36:09 +020038-a::
39--all::
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010040 checks out all files in the index. Cannot be used
Junio C Hamanofd25c822005-10-17 17:38:09 -070041 together with explicit filenames.
David Greaves2cf565c2005-05-10 22:32:30 +010042
Stephan Beyer32402402008-06-08 03:36:09 +020043-n::
44--no-create::
David Greaves2cf565c2005-05-10 22:32:30 +010045 Don't checkout new files, only refresh files already checked
46 out.
47
48--prefix=<string>::
49 When creating files, prepend <string> (usually a directory
50 including a trailing /)
51
Shawn Pearcede84f992006-03-05 03:24:15 -050052--stage=<number>|all::
Junio C Hamano3bd348a2005-12-07 00:29:51 -080053 Instead of checking out unmerged entries, copy out the
54 files from named stage. <number> must be between 1 and 3.
Shawn Pearcede84f992006-03-05 03:24:15 -050055 Note: --stage=all automatically implies --temp.
56
57--temp::
58 Instead of copying the files to the working directory
59 write the content to temporary files. The temporary name
60 associations will be written to stdout.
Junio C Hamano3bd348a2005-12-07 00:29:51 -080061
Shawn Pearce9debe632006-02-28 21:43:33 -050062--stdin::
63 Instead of taking list of paths from the command line,
64 read list of paths from the standard input. Paths are
65 separated by LF (i.e. one path per line) by default.
66
67-z::
68 Only meaningful with `--stdin`; paths are separated with
69 NUL character instead of LF.
70
seane9940042006-05-05 15:05:24 -040071\--::
David Greaves2cf565c2005-05-10 22:32:30 +010072 Do not interpret any more arguments as options.
73
Junio C Hamanofd25c822005-10-17 17:38:09 -070074The order of the flags used to matter, but not anymore.
David Greaves2cf565c2005-05-10 22:32:30 +010075
Jonathan Niederb1889c32008-06-30 01:09:04 -050076Just doing `git checkout-index` does nothing. You probably meant
77`git checkout-index -a`. And if you want to force it, you want
78`git checkout-index -f -a`.
David Greaves2cf565c2005-05-10 22:32:30 +010079
80Intuitiveness is not the goal here. Repeatability is. The reason for
Jon Loeliger61f693b2005-12-05 23:13:03 -060081the "no arguments means no work" behavior is that from scripts you are
82supposed to be able to do:
David Greaves2cf565c2005-05-10 22:32:30 +010083
Jon Loeliger61f693b2005-12-05 23:13:03 -060084----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -050085$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
Jon Loeliger61f693b2005-12-05 23:13:03 -060086----------------
David Greaves2cf565c2005-05-10 22:32:30 +010087
88which will force all existing `*.h` files to be replaced with their
89cached copies. If an empty command line implied "all", then this would
Shawn Pearce9debe632006-02-28 21:43:33 -050090force-refresh everything in the index, which was not the point. But
Thomas Rast0b444cd2010-01-10 00:33:00 +010091since 'git checkout-index' accepts --stdin it would be faster to use:
Shawn Pearce9debe632006-02-28 21:43:33 -050092
93----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -050094$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
Shawn Pearce9debe632006-02-28 21:43:33 -050095----------------
David Greaves2cf565c2005-05-10 22:32:30 +010096
Jon Loeliger61f693b2005-12-05 23:13:03 -060097The `--` is just a good idea when you know the rest will be filenames;
98it will prevent problems with a filename of, for example, `-a`.
99Using `--` is probably a good policy in scripts.
David Greaves2cf565c2005-05-10 22:32:30 +0100100
David Greaves2cf565c2005-05-10 22:32:30 +0100101
Shawn Pearcede84f992006-03-05 03:24:15 -0500102Using --temp or --stage=all
103---------------------------
104When `--temp` is used (or implied by `--stage=all`)
Thomas Rast0b444cd2010-01-10 00:33:00 +0100105'git checkout-index' will create a temporary file for each index
Shawn Pearcede84f992006-03-05 03:24:15 -0500106entry being checked out. The index will not be updated with stat
107information. These options can be useful if the caller needs all
108stages of all unmerged entries so that the unmerged files can be
109processed by an external merge tool.
110
111A listing will be written to stdout providing the association of
112temporary file names to tracked path names. The listing format
113has two variations:
114
115 . tempname TAB path RS
116+
117The first format is what gets used when `--stage` is omitted or
118is not `--stage=all`. The field tempname is the temporary file
119name holding the file content and path is the tracked path name in
120the index. Only the requested entries are output.
121
122 . stage1temp SP stage2temp SP stage3tmp TAB path RS
123+
124The second format is what gets used when `--stage=all`. The three
125stage temporary fields (stage1temp, stage2temp, stage3temp) list the
126name of the temporary file if there is a stage entry in the index
127or `.` if there is no stage entry. Paths which only have a stage 0
128entry will always be omitted from the output.
129
130In both formats RS (the record separator) is newline by default
131but will be the null byte if -z was passed on the command line.
132The temporary file names are always safe strings; they will never
133contain directory separators or whitespace characters. The path
134field is always relative to the current directory and the temporary
135file names are always relative to the top level directory.
136
137If the object being copied out to a temporary file is a symbolic
138link the content of the link will be written to a normal file. It is
139up to the end-user or the Porcelain to make use of this information.
140
141
Jon Loeliger61f693b2005-12-05 23:13:03 -0600142EXAMPLES
143--------
144To update and refresh only the files already checked out::
145+
146----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500147$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
Jon Loeliger61f693b2005-12-05 23:13:03 -0600148----------------
David Greaves2cf565c2005-05-10 22:32:30 +0100149
Thomas Rast0b444cd2010-01-10 00:33:00 +0100150Using 'git checkout-index' to "export an entire tree"::
Jon Loeliger61f693b2005-12-05 23:13:03 -0600151 The prefix ability basically makes it trivial to use
Thomas Rast0b444cd2010-01-10 00:33:00 +0100152 'git checkout-index' as an "export as tree" function.
Jon Loeliger61f693b2005-12-05 23:13:03 -0600153 Just read the desired tree into the index, and do:
154+
155----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500156$ git checkout-index --prefix=git-export-dir/ -a
Jon Loeliger61f693b2005-12-05 23:13:03 -0600157----------------
158+
Jonathan Niederb1889c32008-06-30 01:09:04 -0500159`git checkout-index` will "export" the index into the specified
David Greaves2cf565c2005-05-10 22:32:30 +0100160directory.
Jon Loeliger61f693b2005-12-05 23:13:03 -0600161+
162The final "/" is important. The exported name is literally just
163prefixed with the specified string. Contrast this with the
164following example.
Junio C Hamanofd25c822005-10-17 17:38:09 -0700165
Jon Loeliger61f693b2005-12-05 23:13:03 -0600166Export files with a prefix::
167+
168----------------
Jonathan Niederb1889c32008-06-30 01:09:04 -0500169$ git checkout-index --prefix=.merged- Makefile
Jon Loeliger61f693b2005-12-05 23:13:03 -0600170----------------
171+
172This will check out the currently cached copy of `Makefile`
173into the file `.merged-Makefile`.
David Greaves2cf565c2005-05-10 22:32:30 +0100174
David Greaves2cf565c2005-05-10 22:32:30 +0100175GIT
176---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200177Part of the linkgit:git[1] suite