← 返回命令列表

Linux command

git-ls-files 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

List tracked files

git ls-files

List untracked files

git ls-files --others

List ignored files

git ls-files --ignored --exclude-standard

List modified files

git ls-files --modified

List deleted files

git ls-files --deleted

说明

git ls-files lists files in the index and working tree. It can show tracked, untracked, ignored, modified, and deleted files, making it valuable for scripting and automation. The command provides low-level access to Git's file tracking state. Various flags control which file categories to display. It is commonly used in scripts to enumerate files matching certain criteria, such as finding all untracked files or listing everything ignored by `.gitignore`.

参数

--cached, -c
Show staged files (default).
--modified, -m
Show modified files.
--deleted, -d
Show deleted files.
--others, -o
Show untracked files.
--ignored
Show ignored files.
--exclude-standard
Use standard exclusions.
--stage, -s
Show staging info.
--help
Display help information.

FAQ

What is the git-ls-files command used for?

git ls-files lists files in the index and working tree. It can show tracked, untracked, ignored, modified, and deleted files, making it valuable for scripting and automation. The command provides low-level access to Git's file tracking state. Various flags control which file categories to display. It is commonly used in scripts to enumerate files matching certain criteria, such as finding all untracked files or listing everything ignored by `.gitignore`.

How do I run a basic git-ls-files example?

Run `git ls-files` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --cached, -c do in git-ls-files?

Show staged files (default).