How to remove untracked files?
git clean -f
To remove untracked files from the working directory use git clean -f
.
Since git clean
removes files it's recommended to start with a dry-run using parameter -n. A dry-run will show what is going to be removed without actually removing them.
The -f parameter tells git to remove the files when git clean
is used. The usage of parameter -f is required unless clean.requireForce is configured to false.
Git clean -f
won't remove untracked directories. Add parameter -d to remove directories as well.
git clean -n
Would remove new-file.txt
git clean -f
Removing new-file.txt
See git clean to learn more about it.