How can I make git show a list of the files that are being tracked?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If you want Git to list the files it is currently tracking, the main command is git ls-files. It shows paths known to the index, which is the practical answer to “what files are tracked in this repository?”
That is different from git status, which mixes tracked changes and untracked files into a working-tree report. For a clean tracked-file list, git ls-files is the right tool.
Use git ls-files for the Basic List
Run this in the repository root:
That prints one tracked path per line. The output includes files that are clean, modified, or staged, as long as Git is tracking them.
For example, if your repository contains these tracked files:
then git ls-files prints those paths regardless of whether they changed recently.
Why git status Is Not the Same Answer
Many people start with git status, but that command answers a broader question: “what is the current state of my working tree?” It includes untracked files and groups results by change state.
That can be useful, but it is not a pure tracked-file list. If your goal is inventory, git ls-files is more direct and easier to pipe into other tools.
Filter the Tracked List
Because git ls-files prints plain paths, it works well with standard shell tools.
That restricts the output to tracked Markdown files.
You can also combine it with grep:
This is useful when you want only tracked files under a certain directory or matching a naming pattern.
Show Deleted or Modified Tracked Files Separately
Sometimes the real question is not “what is tracked?” but “which tracked files are currently changed?” Use the related flags on git ls-files when you need that narrower view.
These still operate on tracked files only. They are useful when you want a machine-friendly list without the extra formatting from git status.
A Practical Example in a Script
Even if you do not want a full script, it helps to see why git ls-files is popular in automation.
This pattern lets you lint, archive, count, or inspect tracked files without accidentally including temporary local files.
When Submodules and Ignored Files Matter
Tracked files are not the same as ignored files, generated files, or nested repositories. A few useful distinctions:
- ignored files are excluded by
.gitignore - untracked files exist locally but are not in Git yet
- submodules appear as tracked entries, but their internal files belong to another repository
If your output looks “too short,” check whether you are inside the correct repository and whether some content lives in submodules.
Common Pitfalls
- Using
git statuswhen you really need a complete list of tracked paths. - Assuming modified files stop being tracked. A tracked file remains tracked unless it is removed from Git.
- Forgetting that
git ls-filesreports from the current repository, not from nested submodules automatically. - Expecting ignored or untracked files to appear in the list.
- Running the command outside the repository root and then misreading relative paths.
Summary
- Use
git ls-filesto print the files Git is tracking. - '
git statusanswers a different question and is not a clean tracked-file inventory.' - Add patterns or shell filters when you want only a subset of tracked files.
- Use flags like
--modifiedor--deletedwhen you care about tracked files in a specific state. - Remember that tracked, untracked, ignored, and submodule-managed content are different categories.

