# List Untracked Files For Scripting

You'll generally run `git status` to get an overview of the index and working tree of a git project. This is a *porcelain* command meant for a Git end-user. If you want to do some scripting, you'll want a *plumbing* command like `ls_files`.

The `git ls-files` command will

> Show information about files in the index and the working tree

This command can be used to list all untracked files in the working tree with two flags.

1. The `--others` flag will show untracked files in the output
2. The `--exclude-standard` will use the standard ignore files like `.gitignore` and `.git/info/exclude`.

Put it all together and you've got:

```bash
$ git ls-files --others --exclude-standard
```

In [Make One-Line Commands Interactive with fzf](https://www.youtube.com/watch?v=wf5eXdwfVws), I show how to use this with `fzf` to interactively remove untracked files that are no longer wanted.

[source](https://stackoverflow.com/a/3801554/535590)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/tools/git/list-untracked-files-for-scripting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
