1git-checkout-index(1) 2===================== 3 4NAME 5---- 6git-checkout-index - Copy files from the index to the working tree 7 8 9SYNOPSIS 10-------- 11[verse] 12'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] 13 [--stage=<number>|all] 14 [--temp] 15 [-z] [--stdin] 16 [--] [<file>]\* 17 18DESCRIPTION 19----------- 20Will copy all files listed from the index to the working directory 21(not overwriting existing files). 22 23OPTIONS 24------- 25-u|--index:: 26 update stat information for the checked out entries in 27 the index file. 28 29-q|--quiet:: 30 be quiet if files exist or are not in the index 31 32-f|--force:: 33 forces overwrite of existing files 34 35-a|--all:: 36 checks out all files in the index. Cannot be used 37 together with explicit filenames. 38 39-n|--no-create:: 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 47--stage=<number>|all:: 48 Instead of checking out unmerged entries, copy out the 49 files from named stage. <number> must be between 1 and 3. 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. 56 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 66\--:: 67 Do not interpret any more arguments as options. 68 69The order of the flags used to matter, but not anymore. 70 71Just 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`. 74 75Intuitiveness is not the goal here. Repeatability is. The reason for 76the "no arguments means no work" behavior is that from scripts you are 77supposed to be able to do: 78 79---------------- 80$ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f -- 81---------------- 82 83which will force all existing `*.h` files to be replaced with their 84cached copies. If an empty command line implied "all", then this would 85force-refresh everything in the index, which was not the point. But 86since 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---------------- 91 92The `--` is just a good idea when you know the rest will be filenames; 93it will prevent problems with a filename of, for example, `-a`. 94Using `--` is probably a good policy in scripts. 95 96 97Using --temp or --stage=all 98--------------------------- 99When `--temp` is used (or implied by `--stage=all`) 100`git-checkout-index` will create a temporary file for each index 101entry being checked out. The index will not be updated with stat 102information. These options can be useful if the caller needs all 103stages of all unmerged entries so that the unmerged files can be 104processed by an external merge tool. 105 106A listing will be written to stdout providing the association of 107temporary file names to tracked path names. The listing format 108has two variations: 109 110 . tempname TAB path RS 111+ 112The first format is what gets used when `--stage` is omitted or 113is not `--stage=all`. The field tempname is the temporary file 114name holding the file content and path is the tracked path name in 115the index. Only the requested entries are output. 116 117 . stage1temp SP stage2temp SP stage3tmp TAB path RS 118+ 119The second format is what gets used when `--stage=all`. The three 120stage temporary fields (stage1temp, stage2temp, stage3temp) list the 121name of the temporary file if there is a stage entry in the index 122or `.` if there is no stage entry. Paths which only have a stage 0 123entry will always be omitted from the output. 124 125In both formats RS (the record separator) is newline by default 126but will be the null byte if -z was passed on the command line. 127The temporary file names are always safe strings; they will never 128contain directory separators or whitespace characters. The path 129field is always relative to the current directory and the temporary 130file names are always relative to the top level directory. 131 132If the object being copied out to a temporary file is a symbolic 133link the content of the link will be written to a normal file. It is 134up to the end-user or the Porcelain to make use of this information. 135 136 137EXAMPLES 138-------- 139To 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 145Using `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 155directory. 156+ 157The final "/" is important. The exported name is literally just 158prefixed with the specified string. Contrast this with the 159following example. 160 161Export files with a prefix:: 162+ 163---------------- 164$ git-checkout-index --prefix=.merged- Makefile 165---------------- 166+ 167This will check out the currently cached copy of `Makefile` 168into the file `.merged-Makefile`. 169 170 171Author 172------ 173Written by Linus Torvalds <torvalds@osdl.org> 174 175 176Documentation 177-------------- 178Documentation by David Greaves, 179Junio C Hamano and the git-list <git@vger.kernel.org>. 180 181 182GIT 183--- 184Part of the linkgit:git[7] suite