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