]>
Commit | Line | Data |
---|---|---|
215a7ad1 | 1 | git-checkout-index(1) |
2cf565c5 | 2 | ===================== |
2cf565c5 DG |
3 | |
4 | NAME | |
5 | ---- | |
c3f0baac | 6 | git-checkout-index - Copy files from the index to the working tree |
2cf565c5 DG |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
353ce815 | 11 | [verse] |
215a7ad1 | 12 | 'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] |
de84f99c SP |
13 | [--stage=<number>|all] |
14 | [--temp] | |
9debe63d SP |
15 | [-z] [--stdin] |
16 | [--] [<file>]\* | |
2cf565c5 DG |
17 | |
18 | DESCRIPTION | |
19 | ----------- | |
5f3aa197 | 20 | Will copy all files listed from the index to the working directory |
2cf565c5 DG |
21 | (not overwriting existing files). |
22 | ||
23 | OPTIONS | |
24 | ------- | |
2db0bfbc | 25 | -u|--index:: |
415e96c8 | 26 | update stat information for the checked out entries in |
5f3aa197 | 27 | the index file. |
415e96c8 | 28 | |
2db0bfbc | 29 | -q|--quiet:: |
5f3aa197 | 30 | be quiet if files exist or are not in the index |
2cf565c5 | 31 | |
2db0bfbc | 32 | -f|--force:: |
2cf565c5 DG |
33 | forces overwrite of existing files |
34 | ||
2db0bfbc | 35 | -a|--all:: |
5f3aa197 | 36 | checks out all files in the index. Cannot be used |
fd25c82a | 37 | together with explicit filenames. |
2cf565c5 | 38 | |
2db0bfbc | 39 | -n|--no-create:: |
2cf565c5 DG |
40 | Don't checkout new files, only refresh files already checked |
41 | out. | |
42 | ||
43 | --prefix=<string>:: | |
44 | When creating files, prepend <string> (usually a directory | |
45 | including a trailing /) | |
46 | ||
de84f99c | 47 | --stage=<number>|all:: |
3bd348ae JH |
48 | Instead of checking out unmerged entries, copy out the |
49 | files from named stage. <number> must be between 1 and 3. | |
de84f99c SP |
50 | Note: --stage=all automatically implies --temp. |
51 | ||
52 | --temp:: | |
53 | Instead of copying the files to the working directory | |
54 | write the content to temporary files. The temporary name | |
55 | associations will be written to stdout. | |
3bd348ae | 56 | |
9debe63d SP |
57 | --stdin:: |
58 | Instead of taking list of paths from the command line, | |
59 | read list of paths from the standard input. Paths are | |
60 | separated by LF (i.e. one path per line) by default. | |
61 | ||
62 | -z:: | |
63 | Only meaningful with `--stdin`; paths are separated with | |
64 | NUL character instead of LF. | |
65 | ||
e994004f | 66 | \--:: |
2cf565c5 DG |
67 | Do not interpret any more arguments as options. |
68 | ||
fd25c82a | 69 | The order of the flags used to matter, but not anymore. |
2cf565c5 | 70 | |
61f693bd JL |
71 | Just doing `git-checkout-index` does nothing. You probably meant |
72 | `git-checkout-index -a`. And if you want to force it, you want | |
73 | `git-checkout-index -f -a`. | |
2cf565c5 DG |
74 | |
75 | Intuitiveness is not the goal here. Repeatability is. The reason for | |
61f693bd JL |
76 | the "no arguments means no work" behavior is that from scripts you are |
77 | supposed to be able to do: | |
2cf565c5 | 78 | |
61f693bd JL |
79 | ---------------- |
80 | $ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f -- | |
81 | ---------------- | |
2cf565c5 DG |
82 | |
83 | which will force all existing `*.h` files to be replaced with their | |
84 | cached copies. If an empty command line implied "all", then this would | |
9debe63d SP |
85 | force-refresh everything in the index, which was not the point. But |
86 | since git-checkout-index accepts --stdin it would be faster to use: | |
87 | ||
88 | ---------------- | |
89 | $ find . -name '*.h' -print0 | git-checkout-index -f -z --stdin | |
90 | ---------------- | |
2cf565c5 | 91 | |
61f693bd JL |
92 | The `--` is just a good idea when you know the rest will be filenames; |
93 | it will prevent problems with a filename of, for example, `-a`. | |
94 | Using `--` is probably a good policy in scripts. | |
2cf565c5 | 95 | |
2cf565c5 | 96 | |
de84f99c SP |
97 | Using --temp or --stage=all |
98 | --------------------------- | |
99 | When `--temp` is used (or implied by `--stage=all`) | |
100 | `git-checkout-index` will create a temporary file for each index | |
101 | entry being checked out. The index will not be updated with stat | |
102 | information. These options can be useful if the caller needs all | |
103 | stages of all unmerged entries so that the unmerged files can be | |
104 | processed by an external merge tool. | |
105 | ||
106 | A listing will be written to stdout providing the association of | |
107 | temporary file names to tracked path names. The listing format | |
108 | has two variations: | |
109 | ||
110 | . tempname TAB path RS | |
111 | + | |
112 | The first format is what gets used when `--stage` is omitted or | |
113 | is not `--stage=all`. The field tempname is the temporary file | |
114 | name holding the file content and path is the tracked path name in | |
115 | the index. Only the requested entries are output. | |
116 | ||
117 | . stage1temp SP stage2temp SP stage3tmp TAB path RS | |
118 | + | |
119 | The second format is what gets used when `--stage=all`. The three | |
120 | stage temporary fields (stage1temp, stage2temp, stage3temp) list the | |
121 | name of the temporary file if there is a stage entry in the index | |
122 | or `.` if there is no stage entry. Paths which only have a stage 0 | |
123 | entry will always be omitted from the output. | |
124 | ||
125 | In both formats RS (the record separator) is newline by default | |
126 | but will be the null byte if -z was passed on the command line. | |
127 | The temporary file names are always safe strings; they will never | |
128 | contain directory separators or whitespace characters. The path | |
129 | field is always relative to the current directory and the temporary | |
130 | file names are always relative to the top level directory. | |
131 | ||
132 | If the object being copied out to a temporary file is a symbolic | |
133 | link the content of the link will be written to a normal file. It is | |
134 | up to the end-user or the Porcelain to make use of this information. | |
135 | ||
136 | ||
61f693bd JL |
137 | EXAMPLES |
138 | -------- | |
139 | To update and refresh only the files already checked out:: | |
140 | + | |
141 | ---------------- | |
142 | $ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh | |
143 | ---------------- | |
144 | ||
145 | Using `git-checkout-index` to "export an entire tree":: | |
146 | The prefix ability basically makes it trivial to use | |
147 | `git-checkout-index` as an "export as tree" function. | |
148 | Just read the desired tree into the index, and do: | |
149 | + | |
150 | ---------------- | |
151 | $ git-checkout-index --prefix=git-export-dir/ -a | |
152 | ---------------- | |
153 | + | |
154 | `git-checkout-index` will "export" the index into the specified | |
2cf565c5 | 155 | directory. |
61f693bd JL |
156 | + |
157 | The final "/" is important. The exported name is literally just | |
158 | prefixed with the specified string. Contrast this with the | |
159 | following example. | |
fd25c82a | 160 | |
61f693bd JL |
161 | Export files with a prefix:: |
162 | + | |
163 | ---------------- | |
164 | $ git-checkout-index --prefix=.merged- Makefile | |
165 | ---------------- | |
166 | + | |
167 | This will check out the currently cached copy of `Makefile` | |
168 | into the file `.merged-Makefile`. | |
2cf565c5 | 169 | |
2cf565c5 DG |
170 | |
171 | Author | |
172 | ------ | |
173 | Written by Linus Torvalds <torvalds@osdl.org> | |
174 | ||
61f693bd | 175 | |
2cf565c5 DG |
176 | Documentation |
177 | -------------- | |
61f693bd JL |
178 | Documentation by David Greaves, |
179 | Junio C Hamano and the git-list <git@vger.kernel.org>. | |
180 | ||
2cf565c5 DG |
181 | |
182 | GIT | |
183 | --- | |
a7154e91 | 184 | Part of the gitlink:git[7] suite |