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