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