.gitignore file specifies the files that Git should ignore.
Sometimes you may need to list all the files that Git should ignore.
In this short note i will show 2 methods of how to list ignored files in Git.
Show Ignored Files in Git
To show all the ignored files in a Git repository, use the
git status command with the
$ git status --ignored - sample output - On branch master Ignored files: (use "git add -f
..." to include in what will be committed) files/latest.tgz vault.txt nothing to commit, working tree clean
The command above is recursively searching for all the
.gitignore files in the repository and lists the files matching the patterns to ignore.
Cool Tip: Show Git config settings! Read more →
Another way to list the ignored files is by using the
git clean command, that removes untracked files from a working tree:
$ git clean -ndX - sample output - Would remove files/latest.tgz Would remove vault.txt
||Don’t actually remove anything, just show what would be done|
||Remove untracked directories in addition to untracked files.|
||Remove only files ignored by Git.|
Cool Tip: Increase VERBOSITY of Git commands! Read more →