{
    "mode": "info",
    "parameter": "git-ls-files",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/git-ls-files/json",
    "generated": "2026-07-10T16:05:40Z",
    "synopsis": "git ls-files [-z] [-t] [-v] [-f]\n(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*\n(-[c|d|o|i|s|u|k|m])*\n[--eol]\n[--deduplicate]\n[-x <pattern>|--exclude=<pattern>]\n[-X <file>|--exclude-from=<file>]\n[--exclude-per-directory=<file>]\n[--exclude-standard]\n[--error-unmatch] [--with-tree=<tree-ish>]\n[--full-name] [--recurse-submodules]\n[--abbrev[=<n>]] [--] [<file>...]",
    "sections": {
        "NAME": {
            "content": "git-ls-files - Show information about files in the index and the\nworking tree\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git ls-files [-z] [-t] [-v] [-f]\n(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*\n(-[c|d|o|i|s|u|k|m])*\n[--eol]\n[--deduplicate]\n[-x <pattern>|--exclude=<pattern>]\n[-X <file>|--exclude-from=<file>]\n[--exclude-per-directory=<file>]\n[--exclude-standard]\n[--error-unmatch] [--with-tree=<tree-ish>]\n[--full-name] [--recurse-submodules]\n[--abbrev[=<n>]] [--] [<file>...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This merges the file listing in the index with the actual working\ndirectory list, and shows different combinations of the two.\n\nOne or more of the options below may be used to determine the files\nshown:\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-c, --cached",
                    "content": "Show cached files in the output (default)\n",
                    "flag": "-c",
                    "long": "--cached"
                },
                {
                    "name": "-d, --deleted",
                    "content": "Show deleted files in the output\n",
                    "flag": "-d",
                    "long": "--deleted"
                },
                {
                    "name": "-m, --modified",
                    "content": "Show modified files in the output\n",
                    "flag": "-m",
                    "long": "--modified"
                },
                {
                    "name": "-o, --others",
                    "content": "Show other (i.e. untracked) files in the output\n",
                    "flag": "-o",
                    "long": "--others"
                },
                {
                    "name": "-i, --ignored",
                    "content": "Show only ignored files in the output. When showing files in the\nindex, print only those matched by an exclude pattern. When showing\n\"other\" files, show only those matched by an exclude pattern.\nStandard ignore rules are not automatically activated, therefore at\nleast one of the --exclude* options is required.\n",
                    "flag": "-i",
                    "long": "--ignored"
                },
                {
                    "name": "-s, --stage",
                    "content": "Show staged contents' mode bits, object name and stage number in\nthe output.\n",
                    "flag": "-s",
                    "long": "--stage"
                },
                {
                    "name": "--directory",
                    "content": "If a whole directory is classified as \"other\", show just its name\n(with a trailing slash) and not its whole contents.\n",
                    "long": "--directory"
                },
                {
                    "name": "--no-empty-directory",
                    "content": "Do not list empty directories. Has no effect without --directory.\n",
                    "long": "--no-empty-directory"
                },
                {
                    "name": "-u, --unmerged",
                    "content": "Show unmerged files in the output (forces --stage)\n",
                    "flag": "-u",
                    "long": "--unmerged"
                },
                {
                    "name": "-k, --killed",
                    "content": "Show files on the filesystem that need to be removed due to\nfile/directory conflicts for checkout-index to succeed.\n",
                    "flag": "-k",
                    "long": "--killed"
                },
                {
                    "name": "-z",
                    "content": "\\0 line termination on output and do not quote filenames. See\nOUTPUT below for more information.\n",
                    "flag": "-z"
                },
                {
                    "name": "--deduplicate",
                    "content": "When only filenames are shown, suppress duplicates that may come\nfrom having multiple stages during a merge, or giving --deleted and\n--modified option at the same time. When any of the -t, --unmerged,\nor --stage option is in use, this option has no effect.\n\n-x <pattern>, --exclude=<pattern>\nSkip untracked files matching pattern. Note that pattern is a shell\nwildcard pattern. See EXCLUDE PATTERNS below for more information.\n\n-X <file>, --exclude-from=<file>\nRead exclude patterns from <file>; 1 per line.\n\n--exclude-per-directory=<file>\nRead additional exclude patterns that apply only to the directory\nand its subdirectories in <file>.\n",
                    "long": "--deduplicate"
                },
                {
                    "name": "--exclude-standard",
                    "content": "Add the standard Git exclusions: .git/info/exclude, .gitignore in\neach directory, and the user's global exclusion file.\n",
                    "long": "--exclude-standard"
                },
                {
                    "name": "--error-unmatch",
                    "content": "If any <file> does not appear in the index, treat this as an error\n(return 1).\n\n--with-tree=<tree-ish>\nWhen using --error-unmatch to expand the user supplied <file> (i.e.\npath pattern) arguments to paths, pretend that paths which were\nremoved in the index since the named <tree-ish> are still present.\nUsing this option with -s or -u options does not make any sense.\n",
                    "long": "--error-unmatch"
                },
                {
                    "name": "-t",
                    "content": "This feature is semi-deprecated. For scripting purpose, git-\nstatus(1) --porcelain and git-diff-files(1) --name-status are\nalmost always superior alternatives, and users should look at git-\nstatus(1) --short or git-diff(1) --name-status for more\nuser-friendly alternatives.\n\nThis option identifies the file status with the following tags\n(followed by a space) at the start of each line:\n\nH\ncached\n\nS\nskip-worktree\n\nM\nunmerged\n\nR\nremoved/deleted\n\nC\nmodified/changed\n\nK\nto be killed\n\n?\nother\n",
                    "flag": "-t"
                },
                {
                    "name": "-v",
                    "content": "Similar to -t, but use lowercase letters for files that are marked\nas assume unchanged (see git-update-index(1)).\n",
                    "flag": "-v"
                },
                {
                    "name": "-f",
                    "content": "Similar to -t, but use lowercase letters for files that are marked\nas fsmonitor valid (see git-update-index(1)).\n",
                    "flag": "-f"
                },
                {
                    "name": "--full-name",
                    "content": "When run from a subdirectory, the command usually outputs paths\nrelative to the current directory. This option forces paths to be\noutput relative to the project top directory.\n",
                    "long": "--full-name"
                },
                {
                    "name": "--recurse-submodules",
                    "content": "Recursively calls ls-files on each active submodule in the\nrepository. Currently there is only support for the --cached mode.\n\n--abbrev[=<n>]\nInstead of showing the full 40-byte hexadecimal object lines, show\nthe shortest prefix that is at least <n> hexdigits long that\nuniquely refers the object. Non default number of digits can be\nspecified with --abbrev=<n>.\n",
                    "long": "--recurse-submodules"
                },
                {
                    "name": "--debug",
                    "content": "After each line that describes a file, add more data about its\ncache entry. This is intended to show as much information as\npossible for manual inspection; the exact format may change at any\ntime.\n",
                    "long": "--debug"
                },
                {
                    "name": "--eol",
                    "content": "Show <eolinfo> and <eolattr> of files. <eolinfo> is the file\ncontent identification used by Git when the \"text\" attribute is\n\"auto\" (or not set and core.autocrlf is not false). <eolinfo> is\neither \"-text\", \"none\", \"lf\", \"crlf\", \"mixed\" or \"\".\n\n\"\" means the file is not a regular file, it is not in the index or\nnot accessible in the working tree.\n\n<eolattr> is the attribute that is used when checking out or\ncommitting, it is either \"\", \"-text\", \"text\", \"text=auto\", \"text\neol=lf\", \"text eol=crlf\". Since Git 2.10 \"text=auto eol=lf\" and\n\"text=auto eol=crlf\" are supported.\n\nBoth the <eolinfo> in the index (\"i/<eolinfo>\") and in the working\ntree (\"w/<eolinfo>\") are shown for regular files, followed by the\n(\"attr/<eolattr>\").\n\n--\nDo not interpret any more arguments as options.\n\n<file>\nFiles to show. If no files are given all files which match the\nother specified criteria are shown.\n",
                    "long": "--eol"
                }
            ]
        },
        "OUTPUT": {
            "content": "git ls-files just outputs the filenames unless --stage is specified in\nwhich case it outputs:\n\n[<tag> ]<mode> <object> <stage> <file>\n\ngit ls-files --eol will show\ni/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>\n\ngit ls-files --unmerged and git ls-files --stage can be used to examine\ndetailed information on unmerged paths.\n\nFor an unmerged path, instead of recording a single mode/SHA-1 pair,\nthe index records up to three such pairs; one from tree O in stage 1, A\nin stage 2, and B in stage 3. This information can be used by the user\n(or the porcelain) to see what should eventually be recorded at the\npath. (see git-read-tree(1) for more information on state)\n\nWithout the -z option, pathnames with \"unusual\" characters are quoted\nas explained for the configuration variable core.quotePath (see git-\nconfig(1)). Using -z the filename is output verbatim and the line is\nterminated by a NUL byte.\n",
            "subsections": []
        },
        "EXCLUDE PATTERNS": {
            "content": "git ls-files can use a list of \"exclude patterns\" when traversing the\ndirectory tree and finding files to show when the flags --others or\n--ignored are specified. gitignore(5) specifies the format of exclude\npatterns.\n\nThese exclude patterns come from these places, in order:\n\n1. The command-line flag --exclude=<pattern> specifies a single\npattern. Patterns are ordered in the same order they appear in the\ncommand line.\n\n2. The command-line flag --exclude-from=<file> specifies a file\ncontaining a list of patterns. Patterns are ordered in the same\norder they appear in the file.\n\n3. The command-line flag --exclude-per-directory=<name> specifies a\nname of the file in each directory git ls-files examines, normally\n.gitignore. Files in deeper directories take precedence. Patterns\nare ordered in the same order they appear in the files.\n\nA pattern specified on the command line with --exclude or read from the\nfile specified with --exclude-from is relative to the top of the\ndirectory tree. A pattern read from a file specified by\n--exclude-per-directory is relative to the directory that the pattern\nfile appears in.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-read-tree(1), gitignore(5)\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.34.1                        02/26/2026                   GIT-LS-FILES(1)",
            "subsections": []
        }
    },
    "summary": "git-ls-files - Show information about files in the index and the working tree",
    "flags": [
        {
            "flag": "-c",
            "long": "--cached",
            "arg": null,
            "description": "Show cached files in the output (default)"
        },
        {
            "flag": "-d",
            "long": "--deleted",
            "arg": null,
            "description": "Show deleted files in the output"
        },
        {
            "flag": "-m",
            "long": "--modified",
            "arg": null,
            "description": "Show modified files in the output"
        },
        {
            "flag": "-o",
            "long": "--others",
            "arg": null,
            "description": "Show other (i.e. untracked) files in the output"
        },
        {
            "flag": "-i",
            "long": "--ignored",
            "arg": null,
            "description": "Show only ignored files in the output. When showing files in the index, print only those matched by an exclude pattern. When showing \"other\" files, show only those matched by an exclude pattern. Standard ignore rules are not automatically activated, therefore at least one of the --exclude* options is required."
        },
        {
            "flag": "-s",
            "long": "--stage",
            "arg": null,
            "description": "Show staged contents' mode bits, object name and stage number in the output."
        },
        {
            "flag": "",
            "long": "--directory",
            "arg": null,
            "description": "If a whole directory is classified as \"other\", show just its name (with a trailing slash) and not its whole contents."
        },
        {
            "flag": "",
            "long": "--no-empty-directory",
            "arg": null,
            "description": "Do not list empty directories. Has no effect without --directory."
        },
        {
            "flag": "-u",
            "long": "--unmerged",
            "arg": null,
            "description": "Show unmerged files in the output (forces --stage)"
        },
        {
            "flag": "-k",
            "long": "--killed",
            "arg": null,
            "description": "Show files on the filesystem that need to be removed due to file/directory conflicts for checkout-index to succeed."
        },
        {
            "flag": "-z",
            "long": null,
            "arg": null,
            "description": "\\0 line termination on output and do not quote filenames. See OUTPUT below for more information."
        },
        {
            "flag": "",
            "long": "--deduplicate",
            "arg": null,
            "description": "When only filenames are shown, suppress duplicates that may come from having multiple stages during a merge, or giving --deleted and --modified option at the same time. When any of the -t, --unmerged, or --stage option is in use, this option has no effect. -x <pattern>, --exclude=<pattern> Skip untracked files matching pattern. Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS below for more information. -X <file>, --exclude-from=<file> Read exclude patterns from <file>; 1 per line. --exclude-per-directory=<file> Read additional exclude patterns that apply only to the directory and its subdirectories in <file>."
        },
        {
            "flag": "",
            "long": "--exclude-standard",
            "arg": null,
            "description": "Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user's global exclusion file."
        },
        {
            "flag": "",
            "long": "--error-unmatch",
            "arg": null,
            "description": "If any <file> does not appear in the index, treat this as an error (return 1). --with-tree=<tree-ish> When using --error-unmatch to expand the user supplied <file> (i.e. path pattern) arguments to paths, pretend that paths which were removed in the index since the named <tree-ish> are still present. Using this option with -s or -u options does not make any sense."
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "This feature is semi-deprecated. For scripting purpose, git- status(1) --porcelain and git-diff-files(1) --name-status are almost always superior alternatives, and users should look at git- status(1) --short or git-diff(1) --name-status for more user-friendly alternatives. This option identifies the file status with the following tags (followed by a space) at the start of each line: H cached S skip-worktree M unmerged R removed/deleted C modified/changed K to be killed ? other"
        },
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": "Similar to -t, but use lowercase letters for files that are marked as assume unchanged (see git-update-index(1))."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": "Similar to -t, but use lowercase letters for files that are marked as fsmonitor valid (see git-update-index(1))."
        },
        {
            "flag": "",
            "long": "--full-name",
            "arg": null,
            "description": "When run from a subdirectory, the command usually outputs paths relative to the current directory. This option forces paths to be output relative to the project top directory."
        },
        {
            "flag": "",
            "long": "--recurse-submodules",
            "arg": null,
            "description": "Recursively calls ls-files on each active submodule in the repository. Currently there is only support for the --cached mode. --abbrev[=<n>] Instead of showing the full 40-byte hexadecimal object lines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>."
        },
        {
            "flag": "",
            "long": "--debug",
            "arg": null,
            "description": "After each line that describes a file, add more data about its cache entry. This is intended to show as much information as possible for manual inspection; the exact format may change at any time."
        },
        {
            "flag": "",
            "long": "--eol",
            "arg": null,
            "description": "Show <eolinfo> and <eolattr> of files. <eolinfo> is the file content identification used by Git when the \"text\" attribute is \"auto\" (or not set and core.autocrlf is not false). <eolinfo> is either \"-text\", \"none\", \"lf\", \"crlf\", \"mixed\" or \"\". \"\" means the file is not a regular file, it is not in the index or not accessible in the working tree. <eolattr> is the attribute that is used when checking out or committing, it is either \"\", \"-text\", \"text\", \"text=auto\", \"text eol=lf\", \"text eol=crlf\". Since Git 2.10 \"text=auto eol=lf\" and \"text=auto eol=crlf\" are supported. Both the <eolinfo> in the index (\"i/<eolinfo>\") and in the working tree (\"w/<eolinfo>\") are shown for regular files, followed by the (\"attr/<eolattr>\"). -- Do not interpret any more arguments as options. <file> Files to show. If no files are given all files which match the other specified criteria are shown."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "git-read-tree",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-read-tree/1/json"
        },
        {
            "name": "gitignore",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/gitignore/5/json"
        }
    ]
}