Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 1 | git-checkout-index(1) |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 2 | ===================== |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | c3f0baa | 2007-01-18 15:53:37 -0800 | [diff] [blame] | 6 | git-checkout-index - Copy files from the index to the working tree |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Jonas Fonseca | 353ce81 | 2005-12-31 18:37:15 +0100 | [diff] [blame] | 11 | [verse] |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 12 | 'git checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] |
Shawn Pearce | de84f99 | 2006-03-05 03:24:15 -0500 | [diff] [blame] | 13 | [--stage=<number>|all] |
| 14 | [--temp] |
Shawn Pearce | 9debe63 | 2006-02-28 21:43:33 -0500 | [diff] [blame] | 15 | [-z] [--stdin] |
Štěpán Němec | 0adda93 | 2010-10-08 19:31:17 +0200 | [diff] [blame] | 16 | [--] [<file>...] |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 17 | |
| 18 | DESCRIPTION |
| 19 | ----------- |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 20 | Will copy all files listed from the index to the working directory |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 21 | (not overwriting existing files). |
| 22 | |
| 23 | OPTIONS |
| 24 | ------- |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 25 | -u:: |
| 26 | --index:: |
Junio C Hamano | 415e96c | 2005-05-15 14:23:12 -0700 | [diff] [blame] | 27 | update stat information for the checked out entries in |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 28 | the index file. |
Junio C Hamano | 415e96c | 2005-05-15 14:23:12 -0700 | [diff] [blame] | 29 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 30 | -q:: |
| 31 | --quiet:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 32 | be quiet if files exist or are not in the index |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 33 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 34 | -f:: |
| 35 | --force:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 36 | forces overwrite of existing files |
| 37 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 38 | -a:: |
| 39 | --all:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 40 | checks out all files in the index. Cannot be used |
Junio C Hamano | fd25c82 | 2005-10-17 17:38:09 -0700 | [diff] [blame] | 41 | together with explicit filenames. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 42 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 43 | -n:: |
| 44 | --no-create:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 45 | 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 Pearce | de84f99 | 2006-03-05 03:24:15 -0500 | [diff] [blame] | 52 | --stage=<number>|all:: |
Junio C Hamano | 3bd348a | 2005-12-07 00:29:51 -0800 | [diff] [blame] | 53 | Instead of checking out unmerged entries, copy out the |
| 54 | files from named stage. <number> must be between 1 and 3. |
Shawn Pearce | de84f99 | 2006-03-05 03:24:15 -0500 | [diff] [blame] | 55 | 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 Hamano | 3bd348a | 2005-12-07 00:29:51 -0800 | [diff] [blame] | 61 | |
Shawn Pearce | 9debe63 | 2006-02-28 21:43:33 -0500 | [diff] [blame] | 62 | --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 | |
sean | e994004 | 2006-05-05 15:05:24 -0400 | [diff] [blame] | 71 | \--:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 72 | Do not interpret any more arguments as options. |
| 73 | |
Junio C Hamano | fd25c82 | 2005-10-17 17:38:09 -0700 | [diff] [blame] | 74 | The order of the flags used to matter, but not anymore. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 75 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 76 | Just 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 Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 79 | |
| 80 | Intuitiveness is not the goal here. Repeatability is. The reason for |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 81 | the "no arguments means no work" behavior is that from scripts you are |
| 82 | supposed to be able to do: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 83 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 84 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 85 | $ find . -name '*.h' -print0 | xargs -0 git checkout-index -f -- |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 86 | ---------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 87 | |
| 88 | which will force all existing `*.h` files to be replaced with their |
| 89 | cached copies. If an empty command line implied "all", then this would |
Shawn Pearce | 9debe63 | 2006-02-28 21:43:33 -0500 | [diff] [blame] | 90 | force-refresh everything in the index, which was not the point. But |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 91 | since 'git checkout-index' accepts --stdin it would be faster to use: |
Shawn Pearce | 9debe63 | 2006-02-28 21:43:33 -0500 | [diff] [blame] | 92 | |
| 93 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 94 | $ find . -name '*.h' -print0 | git checkout-index -f -z --stdin |
Shawn Pearce | 9debe63 | 2006-02-28 21:43:33 -0500 | [diff] [blame] | 95 | ---------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 96 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 97 | The `--` is just a good idea when you know the rest will be filenames; |
| 98 | it will prevent problems with a filename of, for example, `-a`. |
| 99 | Using `--` is probably a good policy in scripts. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 100 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 101 | |
Shawn Pearce | de84f99 | 2006-03-05 03:24:15 -0500 | [diff] [blame] | 102 | Using --temp or --stage=all |
| 103 | --------------------------- |
| 104 | When `--temp` is used (or implied by `--stage=all`) |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 105 | 'git checkout-index' will create a temporary file for each index |
Shawn Pearce | de84f99 | 2006-03-05 03:24:15 -0500 | [diff] [blame] | 106 | entry being checked out. The index will not be updated with stat |
| 107 | information. These options can be useful if the caller needs all |
| 108 | stages of all unmerged entries so that the unmerged files can be |
| 109 | processed by an external merge tool. |
| 110 | |
| 111 | A listing will be written to stdout providing the association of |
| 112 | temporary file names to tracked path names. The listing format |
| 113 | has two variations: |
| 114 | |
| 115 | . tempname TAB path RS |
| 116 | + |
| 117 | The first format is what gets used when `--stage` is omitted or |
| 118 | is not `--stage=all`. The field tempname is the temporary file |
| 119 | name holding the file content and path is the tracked path name in |
| 120 | the index. Only the requested entries are output. |
| 121 | |
| 122 | . stage1temp SP stage2temp SP stage3tmp TAB path RS |
| 123 | + |
| 124 | The second format is what gets used when `--stage=all`. The three |
| 125 | stage temporary fields (stage1temp, stage2temp, stage3temp) list the |
| 126 | name of the temporary file if there is a stage entry in the index |
| 127 | or `.` if there is no stage entry. Paths which only have a stage 0 |
| 128 | entry will always be omitted from the output. |
| 129 | |
| 130 | In both formats RS (the record separator) is newline by default |
| 131 | but will be the null byte if -z was passed on the command line. |
| 132 | The temporary file names are always safe strings; they will never |
| 133 | contain directory separators or whitespace characters. The path |
| 134 | field is always relative to the current directory and the temporary |
| 135 | file names are always relative to the top level directory. |
| 136 | |
| 137 | If the object being copied out to a temporary file is a symbolic |
| 138 | link the content of the link will be written to a normal file. It is |
| 139 | up to the end-user or the Porcelain to make use of this information. |
| 140 | |
| 141 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 142 | EXAMPLES |
| 143 | -------- |
| 144 | To update and refresh only the files already checked out:: |
| 145 | + |
| 146 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 147 | $ git checkout-index -n -f -a && git update-index --ignore-missing --refresh |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 148 | ---------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 149 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 150 | Using 'git checkout-index' to "export an entire tree":: |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 151 | The prefix ability basically makes it trivial to use |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 152 | 'git checkout-index' as an "export as tree" function. |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 153 | Just read the desired tree into the index, and do: |
| 154 | + |
| 155 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 156 | $ git checkout-index --prefix=git-export-dir/ -a |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 157 | ---------------- |
| 158 | + |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 159 | `git checkout-index` will "export" the index into the specified |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 160 | directory. |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 161 | + |
| 162 | The final "/" is important. The exported name is literally just |
| 163 | prefixed with the specified string. Contrast this with the |
| 164 | following example. |
Junio C Hamano | fd25c82 | 2005-10-17 17:38:09 -0700 | [diff] [blame] | 165 | |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 166 | Export files with a prefix:: |
| 167 | + |
| 168 | ---------------- |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 169 | $ git checkout-index --prefix=.merged- Makefile |
Jon Loeliger | 61f693b | 2005-12-05 23:13:03 -0600 | [diff] [blame] | 170 | ---------------- |
| 171 | + |
| 172 | This will check out the currently cached copy of `Makefile` |
| 173 | into the file `.merged-Makefile`. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 174 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 175 | GIT |
| 176 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 177 | Part of the linkgit:git[1] suite |