The git clean command removes untracked files from your working directory. This is really more of a convenience command, since it’s trivial to see which files are untracked with git status and remove them manually. Like an ordinary rm command, git clean is not undoable, so make sure you really want to delete the untracked files before you run it.

#Perform a “dry run” of git clean.This will show you which files are going to be removed without actually doing it.
git clean -n

#Remove untracked files from the current directory. The -f (force) flag 
git clean -f

#Remove untracked files, but limit the operation to the specified path.
git clean -f 

#Remove untracked files and untracked directories from the current directory.
git clean -df

#Remove untracked files from the current directory as well as any files that Git usually ignores.
git clean -xf

Leave a Reply

Your email address will not be published. Required fields are marked *