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