Remove untracked files from current git branch
git clean -f
git clean -n
This is a good practice to view files before deleting them. First make sure the files that are going to be deleted is needed or not then run first command.
Below are some options available in GIT for you to delete files, directories and ignored files.
- If you want to remove directories then run git clean -f -d or git clean -fd
- If you want to remove only ignored files then run git clean -f -X or git clean -fX
- If you want remove ignored and non-ignored files then run git clean -f -x or git clean -fx