Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

Git Clean

I found that the command "make clean" seldom cleans all the files there were created when compiling. Luckily, Git has a better solution that cleans all untracked files while being faster. The command is:

git clean d -f

The "-f" argument is a force delete. Alternatively, you can use the "-n" argument that is a dry run that will only list the files that would be deleted instead of deleting them.

The optional "-d" argument will delete all untracked directories as well as untracked files. Without this option, untracked directories and untracked files in untracked directories will not be deleted.

The Git clean command will not delete any files listed in the repository's Git ignore (".gitignore") configuration file

Do not forget that the Git clean command can and will delete important files that you do not want deleted, so please be very careful when running this command.

by Phil for Humanity
on 11/07/2012

Related Articles
 » Git Status
 » Git Version Tree: Gitk
 » Git Log and Cat-File