Here I wanted to give you some useful commands that do the required job of cleaning the untracked or ignored files and directories from the git repo.
This is written according to the git documentation provided here. This should not be considered as a complete guide to git clean.
- Run this command to see what are the files or dirs going be removed: git clean -n or git clean --dry-run
So it doesn't actually remove anything, just show what would be done. - Run this command to delete the files or directories actually: git cleanBeware that it removes the files and directories permanently!!
If you want to remove directories, run git clean -f -d or git clean -fd
If you want to remove ignored files, run git clean -f -X or git clean -fX
If you want to remove ignored and non-ignored files, run git clean -f -x or git clean -fx
It is always advisable to have a glance at the complete documentation at git! Have a look at git clean documentation for a clear understanding.