I think this answer should resolve all your queries.
Step 1 is to show what will be deleted by using the -n option:
# Print out the list of files and directories which will be removed (dry run)
git clean -n -d
Step 2 Clean Step - beware: this will delete files:
# Delete the files from the repository
git clean -f
- To remove directories, run git clean -f -d or git clean -fd
- To remove ignored files, run git clean -f -X or git clean -fX
- To remove ignored and non-ignored files, run git clean -f -x or git clean -fx
Note the case difference on the X for the two latter commands.
If clean.requireForce is set to "true" (the default) in your
configuration, one needs to specify -f otherwise nothing will actually
happen.
Again see the git-clean docs for more information.
git clean -n
doesn't actually remove the files, but actually shows which files are going to be removed.
git clean -f
removes and deletes the files from the repository.