7 git-ls-files - Information about files in the cache/working directory
12 'git-ls-files' [-z] [-t]
13 (--[cached|deleted|others|ignored|stage|unmerged|killed])\*
15 [-x <pattern>|--exclude=<pattern>]
16 [-X <file>|--exclude-from=<file>]
17 [--exclude-per-directory=<file>]
21 This merges the file listing in the directory cache index with the
22 actual working directory list, and shows different combinations of the
25 One or more of the options below may be used to determine the files
31 Show cached files in the output (default)
34 Show deleted files in the output
37 Show other files in the output
40 Show ignored files in the output
41 Note the this also reverses any exclude list present.
44 Show stage files in the output
47 Show unmerged files in the output (forces --stage)
50 Show files on the filesystem that need to be removed due
51 to file/directory conflicts for checkout-cache to
55 \0 line termination on output
57 -x|--exclude=<pattern>::
58 Skips files matching pattern.
59 Note that pattern is a shell wildcard pattern.
61 -X|--exclude-from=<file>::
62 exclude patterns are read from <file>; 1 per line.
64 --exclude-per-directory=<file>::
65 read additional exclude patterns that apply only to the
66 directory and its subdirectories in <file>.
69 Identify the file status with the following tags (followed by
70 a space) at the start of each line:
79 show files just outputs the filename unless '--stage' is specified in
80 which case it outputs:
82 [<tag> ]<mode> <object> <stage> <file>
84 "git-ls-files --unmerged" and "git-ls-files --stage" can be used to examine
85 detailed information on unmerged paths.
87 For an unmerged path, instead of recording a single mode/SHA1 pair,
88 the dircache records up to three such pairs; one from tree O in stage
89 1, A in stage 2, and B in stage 3. This information can be used by
90 the user (or the porcelain) to see what should eventually be recorded at the
91 path. (see read-cache for more information on state)
97 'git-ls-files' can use a list of "exclude patterns" when
98 traversing the directory tree and finding files to show when the
99 flags --others or --ignored are specified.
101 These exclude patterns come from these places:
103 (1) command line flag --exclude=<pattern> specifies a single
106 (2) command line flag --exclude-from=<file> specifies a list of
107 patterns stored in a file.
109 (3) command line flag --exclude-per-directory=<name> specifies
110 a name of the file in each directory 'git-ls-files'
111 examines, and if exists, its contents are used as an
112 additional list of patterns.
114 An exclude pattern file used by (2) and (3) contains one pattern
115 per line. A line that starts with a '#' can be used as comment
118 There are three lists of patterns that are in effect at a given
119 time. They are built and ordered in the following way:
121 * --exclude=<pattern> from the command line; patterns are
122 ordered in the same order as they appear on the command line.
124 * lines read from --exclude-from=<file>; patterns are ordered
125 in the same order as they appear in the file.
127 * When --exclude-per-directory=<name> is specified, upon
128 entering a directory that has such a file, its contents are
129 appended at the end of the current "list of patterns". They
130 are popped off when leaving the directory.
132 Each pattern in the pattern list specifies "a match pattern" and
133 optionally the fate; either a file that matches the pattern is
134 considered excluded or included. A filename is matched against
135 the patterns in the three lists; the --exclude-from list is
136 checked first, then the --exclude-per-directory list, and then
137 finally the --exclude list. The last match determines its fate.
138 If there is no match in the three lists, the fate is "included".
140 A pattern specified on the command line with --exclude or read
141 from the file specified with --exclude-from is relative to the
142 top of the directory tree. A pattern read from a file specified
143 by --exclude-per-directory is relative to the directory that the
144 pattern file appears in.
146 An exclude pattern is of the following format:
148 - an optional prefix '!' which means that the fate this pattern
149 specifies is "include", not the usual "exclude"; the
150 remainder of the pattern string is interpreted according to
153 - if it does not contain a slash '/', it is a shell glob
154 pattern and used to match against the filename without
155 leading directories (i.e. the same way as the current
158 - otherwise, it is a shell glob pattern, suitable for
159 consumption by fnmatch(3) with FNM_PATHNAME flag. I.e. a
160 slash in the pattern must match a slash in the pathname.
161 "Documentation/*.html" matches "Documentation/git.html" but
162 not "ppc/ppc.html". As a natural exception, "/*.c" matches
163 "cat-file.c" but not "mozilla-sha1/sha1.c".
168 # ignore objects and archives, anywhere in the tree.
170 $ cat Documentation/.gitignore
171 # ignore generated html files,
173 # except foo.html which is maintained by hand
175 $ git-ls-files --ignored \
176 --exclude='Documentation/*.[0-9]' \
177 --exclude-from=.git/ignore \
178 --exclude-per-directory=.gitignore
183 link:read-cache.html[read-cache]
188 Written by Linus Torvalds <torvalds@osdl.org>
192 Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
196 Part of the link:git.html[git] suite