]>
Commit | Line | Data |
---|---|---|
2cf565c5 DG |
1 | git-ls-files(1) |
2 | =============== | |
2cf565c5 DG |
3 | |
4 | NAME | |
5 | ---- | |
5f3aa197 | 6 | git-ls-files - Information about files in the index/working directory |
2cf565c5 DG |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
f9666adf JH |
11 | [verse] |
12 | 'git-ls-files' [-z] [-t] [-v] | |
b0391890 JH |
13 | (--[cached|deleted|others|ignored|stage|unmerged|killed|modified])\* |
14 | (-[c|d|o|i|s|u|k|m])\* | |
2cf565c5 DG |
15 | [-x <pattern>|--exclude=<pattern>] |
16 | [-X <file>|--exclude-from=<file>] | |
9a84074d | 17 | [--exclude-per-directory=<file>] |
c8af25ca | 18 | [--error-unmatch] |
9a84074d | 19 | [--full-name] [--] [<file>]\* |
2cf565c5 DG |
20 | |
21 | DESCRIPTION | |
22 | ----------- | |
23 | This merges the file listing in the directory cache index with the | |
24 | actual working directory list, and shows different combinations of the | |
25 | two. | |
26 | ||
27 | One or more of the options below may be used to determine the files | |
28 | shown: | |
29 | ||
30 | OPTIONS | |
31 | ------- | |
32 | -c|--cached:: | |
33 | Show cached files in the output (default) | |
34 | ||
35 | -d|--deleted:: | |
36 | Show deleted files in the output | |
37 | ||
b0391890 JH |
38 | -m|--modified:: |
39 | Show modified files in the output | |
40 | ||
2cf565c5 DG |
41 | -o|--others:: |
42 | Show other files in the output | |
43 | ||
44 | -i|--ignored:: | |
45 | Show ignored files in the output | |
46 | Note the this also reverses any exclude list present. | |
47 | ||
48 | -s|--stage:: | |
49 | Show stage files in the output | |
50 | ||
a3259570 PB |
51 | --directory:: |
52 | If a whole directory is classified as "other", show just its | |
53 | name (with a trailing slash) and not its whole contents. | |
54 | ||
b0a3de42 PB |
55 | --no-empty-directory:: |
56 | Do not list empty directories. Has no effect without --directory. | |
57 | ||
2cf565c5 DG |
58 | -u|--unmerged:: |
59 | Show unmerged files in the output (forces --stage) | |
60 | ||
6ca45943 JH |
61 | -k|--killed:: |
62 | Show files on the filesystem that need to be removed due | |
ab182478 | 63 | to file/directory conflicts for checkout-index to |
6ca45943 JH |
64 | succeed. |
65 | ||
2cf565c5 | 66 | -z:: |
d88156e9 | 67 | \0 line termination on output. |
2cf565c5 DG |
68 | |
69 | -x|--exclude=<pattern>:: | |
70 | Skips files matching pattern. | |
71 | Note that pattern is a shell wildcard pattern. | |
72 | ||
73 | -X|--exclude-from=<file>:: | |
74 | exclude patterns are read from <file>; 1 per line. | |
30b0535f JH |
75 | |
76 | --exclude-per-directory=<file>:: | |
77 | read additional exclude patterns that apply only to the | |
78 | directory and its subdirectories in <file>. | |
2cf565c5 | 79 | |
c8af25ca CW |
80 | --error-unmatch:: |
81 | If any <file> does not appear in the index, treat this as an | |
82 | error (return 1). | |
83 | ||
2cf565c5 DG |
84 | -t:: |
85 | Identify the file status with the following tags (followed by | |
86 | a space) at the start of each line: | |
df8baa42 JF |
87 | H:: cached |
88 | M:: unmerged | |
89 | R:: removed/deleted | |
89438677 | 90 | C:: modified/changed |
df8baa42 | 91 | K:: to be killed |
41ac06c7 | 92 | ?:: other |
2cf565c5 | 93 | |
f9666adf JH |
94 | -v:: |
95 | Similar to `-t`, but use lowercase letters for files | |
96 | that are marked as 'always matching index'. | |
97 | ||
9a84074d JH |
98 | --full-name:: |
99 | When run from a subdirectory, the command usually | |
100 | outputs paths relative to the current directory. This | |
101 | option forces paths to be output relative to the project | |
102 | top directory. | |
103 | ||
500b97e4 FK |
104 | --:: |
105 | Do not interpret any more arguments as options. | |
106 | ||
107 | <file>:: | |
108 | Files to show. If no files are given all files which match the other | |
109 | specified criteria are shown. | |
110 | ||
2cf565c5 DG |
111 | Output |
112 | ------ | |
113 | show files just outputs the filename unless '--stage' is specified in | |
114 | which case it outputs: | |
115 | ||
116 | [<tag> ]<mode> <object> <stage> <file> | |
117 | ||
118 | "git-ls-files --unmerged" and "git-ls-files --stage" can be used to examine | |
119 | detailed information on unmerged paths. | |
120 | ||
121 | For an unmerged path, instead of recording a single mode/SHA1 pair, | |
122 | the dircache records up to three such pairs; one from tree O in stage | |
123 | 1, A in stage 2, and B in stage 3. This information can be used by | |
2c6e4771 | 124 | the user (or the porcelain) to see what should eventually be recorded at the |
baeda3a7 | 125 | path. (see git-read-tree for more information on state) |
2cf565c5 | 126 | |
d88156e9 JH |
127 | When `-z` option is not used, TAB, LF, and backslash characters |
128 | in pathnames are represented as `\t`, `\n`, and `\\`, | |
129 | respectively. | |
130 | ||
30b0535f JH |
131 | |
132 | Exclude Patterns | |
133 | ---------------- | |
134 | ||
135 | 'git-ls-files' can use a list of "exclude patterns" when | |
136 | traversing the directory tree and finding files to show when the | |
137 | flags --others or --ignored are specified. | |
138 | ||
139 | These exclude patterns come from these places: | |
140 | ||
df8baa42 | 141 | 1. command line flag --exclude=<pattern> specifies a single |
30b0535f JH |
142 | pattern. |
143 | ||
df8baa42 | 144 | 2. command line flag --exclude-from=<file> specifies a list of |
30b0535f JH |
145 | patterns stored in a file. |
146 | ||
df8baa42 | 147 | 3. command line flag --exclude-per-directory=<name> specifies |
30b0535f JH |
148 | a name of the file in each directory 'git-ls-files' |
149 | examines, and if exists, its contents are used as an | |
150 | additional list of patterns. | |
151 | ||
152 | An exclude pattern file used by (2) and (3) contains one pattern | |
153 | per line. A line that starts with a '#' can be used as comment | |
154 | for readability. | |
155 | ||
1df092d2 JH |
156 | There are three lists of patterns that are in effect at a given |
157 | time. They are built and ordered in the following way: | |
30b0535f | 158 | |
1df092d2 JH |
159 | * --exclude=<pattern> from the command line; patterns are |
160 | ordered in the same order as they appear on the command line. | |
161 | ||
162 | * lines read from --exclude-from=<file>; patterns are ordered | |
163 | in the same order as they appear in the file. | |
30b0535f JH |
164 | |
165 | * When --exclude-per-directory=<name> is specified, upon | |
166 | entering a directory that has such a file, its contents are | |
167 | appended at the end of the current "list of patterns". They | |
168 | are popped off when leaving the directory. | |
169 | ||
170 | Each pattern in the pattern list specifies "a match pattern" and | |
2c6e4771 | 171 | optionally the fate; either a file that matches the pattern is |
1df092d2 JH |
172 | considered excluded or included. A filename is matched against |
173 | the patterns in the three lists; the --exclude-from list is | |
174 | checked first, then the --exclude-per-directory list, and then | |
175 | finally the --exclude list. The last match determines its fate. | |
176 | If there is no match in the three lists, the fate is "included". | |
30b0535f JH |
177 | |
178 | A pattern specified on the command line with --exclude or read | |
179 | from the file specified with --exclude-from is relative to the | |
180 | top of the directory tree. A pattern read from a file specified | |
181 | by --exclude-per-directory is relative to the directory that the | |
182 | pattern file appears in. | |
183 | ||
184 | An exclude pattern is of the following format: | |
185 | ||
186 | - an optional prefix '!' which means that the fate this pattern | |
187 | specifies is "include", not the usual "exclude"; the | |
188 | remainder of the pattern string is interpreted according to | |
189 | the following rules. | |
190 | ||
191 | - if it does not contain a slash '/', it is a shell glob | |
192 | pattern and used to match against the filename without | |
193 | leading directories (i.e. the same way as the current | |
194 | implementation). | |
195 | ||
196 | - otherwise, it is a shell glob pattern, suitable for | |
197 | consumption by fnmatch(3) with FNM_PATHNAME flag. I.e. a | |
198 | slash in the pattern must match a slash in the pathname. | |
df8baa42 | 199 | "Documentation/\*.html" matches "Documentation/git.html" but |
30b0535f JH |
200 | not "ppc/ppc.html". As a natural exception, "/*.c" matches |
201 | "cat-file.c" but not "mozilla-sha1/sha1.c". | |
202 | ||
203 | An example: | |
204 | ||
df8baa42 | 205 | -------------------------------------------------------------- |
30b0535f JH |
206 | $ cat .git/ignore |
207 | # ignore objects and archives, anywhere in the tree. | |
208 | *.[oa] | |
209 | $ cat Documentation/.gitignore | |
210 | # ignore generated html files, | |
1df092d2 | 211 | *.html |
30b0535f JH |
212 | # except foo.html which is maintained by hand |
213 | !foo.html | |
30b0535f JH |
214 | $ git-ls-files --ignored \ |
215 | --exclude='Documentation/*.[0-9]' \ | |
216 | --exclude-from=.git/ignore \ | |
217 | --exclude-per-directory=.gitignore | |
df8baa42 | 218 | -------------------------------------------------------------- |
30b0535f JH |
219 | |
220 | ||
c1bdacf9 DG |
221 | See Also |
222 | -------- | |
a7154e91 | 223 | gitlink:git-read-tree[1] |
2cf565c5 DG |
224 | |
225 | ||
226 | Author | |
227 | ------ | |
228 | Written by Linus Torvalds <torvalds@osdl.org> | |
229 | ||
230 | Documentation | |
231 | -------------- | |
232 | Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. | |
233 | ||
234 | GIT | |
235 | --- | |
a7154e91 | 236 | Part of the gitlink:git[7] suite |
2cf565c5 | 237 |