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.
- The
--othersflag will show untracked files in the output - The
--exclude-standardwill use the standard ignore files like.gitignoreand.git/info/exclude.
Put it all together and you've got:
$ git ls-files --others --exclude-standardIn Make One-Line Commands Interactive with
fzf, I show how to use this with
fzf to interactively remove untracked files that are no longer wanted.