Home Explore Blog CI



git

5th chunk of `Documentation/git-ls-files.adoc`
225f92720dbd6396adb782661ec65efb607b7287b615ab720000000100000bd0
 if you only care about the
"objectname" and "path" fields, you can execute with a specific
"--format" like

	git ls-files --format='%(objectname) %(path)'

FIELD NAMES
-----------
The way each path is shown can be customized by using the
`--format=<format>` option, where the %(fieldname) in the
<format> string for various aspects of the index entry are
interpolated.  The following "fieldname" are understood:

objectmode::
	The mode of the file which is recorded in the index.
objecttype::
	The object type of the file which is recorded in the index.
objectname::
	The name of the file which is recorded in the index.
objectsize[:padded]::
	The object size of the file which is recorded in the index
	("-" if the object is a `commit` or `tree`).
	It also supports a padded format of size with "%(objectsize:padded)".
stage::
	The stage of the file which is recorded in the index.
eolinfo:index::
eolinfo:worktree::
	The <eolinfo> (see the description of the `--eol` option) of
	the contents in the index or in the worktree for the path.
eolattr::
	The <eolattr> (see the description of the `--eol` option)
	that applies to the path.
path::
	The pathname of the file which is recorded in the index.

EXCLUDE PATTERNS
----------------

'git ls-files' can use a list of "exclude patterns" when
traversing the directory tree and finding files to show when the
flags --others or --ignored are specified.  linkgit:gitignore[5]
specifies the format of exclude patterns.

These exclude patterns can be specified from the following places,
in order:

  1. The command-line flag --exclude=<pattern> specifies a
     single pattern.  Patterns are ordered in the same order
     they appear in the command line.

  2. The command-line flag --exclude-from=<file> specifies a
     file containing a list of patterns.  Patterns are ordered
     in the same order they appear in the file.

  3. The command-line flag --exclude-per-directory=<name> specifies
     a name of the file in each directory 'git ls-files'
     examines, normally `.gitignore`.  Files in deeper
     directories take precedence.  Patterns are ordered in the
     same order they appear in the files.

A pattern specified on the command line with --exclude or read
from the file specified with --exclude-from is relative to the
top of the directory tree.  A pattern read from a file specified
by --exclude-per-directory is relative to the directory that the
pattern file appears in.

Generally, you should be able to use `--exclude-standard` when you
want the exclude rules applied the same way as what Porcelain
commands do.  To emulate what `--exclude-standard` specifies, you
can give `--exclude-per-directory=.gitignore`, and then specify:

  1. The file specified by the `core.excludesfile` configuration
     variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.

  2. The `$GIT_DIR/info/exclude` file.

via the `--exclude-from=` option.

SEE ALSO
--------
linkgit:git-read-tree[1], linkgit:gitignore[5]

GIT
---
Part of the linkgit:git[1] suite

Title: Git Ls-Files Customization and Exclude Patterns
Summary
The git ls-files command allows customization of output using the --format option and field names, and also supports exclude patterns to filter files, which can be specified via command-line flags, files, or configuration variables, enabling precise control over the files displayed.