5bff4865f78101b0bb7df23b381f26d61a35a80a
[git.git] / Documentation / git-checkout-index.txt
1 git-checkout-index(1)
2 =====================
3
4 NAME
5 ----
6 git-checkout-index - Copy files from the index to the working directory
7
8
9 SYNOPSIS
10 --------
11 'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
12                    [--] <file>...
13
14 DESCRIPTION
15 -----------
16 Will copy all files listed from the index to the working directory
17 (not overwriting existing files).
18
19 OPTIONS
20 -------
21 -u|--index::
22         update stat information for the checked out entries in
23         the index file.
24
25 -q|--quiet::
26         be quiet if files exist or are not in the index
27
28 -f|--force::
29         forces overwrite of existing files
30
31 -a|--all::
32         checks out all files in the index.  Cannot be used
33         together with explicit filenames.
34
35 -n|--no-create::
36         Don't checkout new files, only refresh files already checked
37         out.
38
39 --prefix=<string>::
40         When creating files, prepend <string> (usually a directory
41         including a trailing /)
42
43 --::
44         Do not interpret any more arguments as options.
45
46 The order of the flags used to matter, but not anymore.
47
48 Just doing "git-checkout-index" does nothing. You probably meant
49 "git-checkout-index -a". And if you want to force it, you want
50 "git-checkout-index -f -a".
51
52 Intuitiveness is not the goal here. Repeatability is. The reason for
53 the "no arguments means no work" thing is that from scripts you are
54 supposed to be able to do things like:
55
56         find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
57
58 which will force all existing `*.h` files to be replaced with their
59 cached copies. If an empty command line implied "all", then this would
60 force-refresh everything in the index, which was not the point.
61
62 To update and refresh only the files already checked out:
63
64         git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
65
66 Oh, and the "--" is just a good idea when you know the rest will be
67 filenames. Just so that you wouldn't have a filename of "-a" causing
68 problems (not possible in the above example, but get used to it in
69 scripting!).
70
71 The prefix ability basically makes it trivial to use
72 git-checkout-index as an "export as tree" function. Just read the
73 desired tree into the index, and do a
74
75         git-checkout-index --prefix=git-export-dir/ -a
76
77 and git-checkout-index will "export" the index into the specified
78 directory.
79
80 NOTE The final "/" is important. The exported name is literally just
81 prefixed with the specified string, so you can also do something like
82
83     git-checkout-index --prefix=.merged- Makefile
84
85 to check out the currently cached copy of `Makefile` into the file
86 `.merged-Makefile`
87
88 Author
89 ------
90 Written by Linus Torvalds <torvalds@osdl.org>
91
92 Documentation
93 --------------
94 Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
95
96 GIT
97 ---
98 Part of the gitlink:git[7] suite
99