Getting a list of all unversioned files in a Git-controlled folder
Or...
git clean -dnx | cut -c 14-
If you don't want to see ignored files,
git clean -dn | cut -c 14-
Actually, if you use git clean
with the -n
or --dry-run
option, it will print out a list untracked files that it would have removed had you run it with the -f
or --force
option. Adding the -d
flag includes directories that are either empty or contain only untracked files.
So you can run this command from within a git repository:
$ git clean -dn
And get output like this:
Would remove dir/untracked_file_1.txtWould remove untracked_file_2.txt
Here's a bonus: It respects your .gitignore file as well, though if you add the -X
flag, it will list only ignored files.
diff <(echo "`git ls-tree -r master | sed 's/.*\t//g'`") <(echo "`find . -type f`") | grep '> .*' | cut -c 3-