

if you want to include untracked directories, use the -di option.You can combine the options when using the interactive mode. It will show a screen that explains all the commands that you can choose from. It will iterate and ask a yes/no prompt on each file. It will show a screen where you will be able to select by numbers the files to choose. It will show a screen where you will be able to filter by pattern the files to choose. Here is a table with all the options that you can select from in interactive mode: Option Here is an example of an output that you can expect when using the interactive mode.

This will output a questionnaire and the ' What now' prompt, where you can select the option that you want. You can activate the interactive mode using the -i option. Using the interactive mode, you will be able to choose exactly what to do with each file. Once you are sure about the removal, use the force -f option. This command will output the directories up for removal. If you want to delete untracked directories you will need to use the -d option.įirst, let's use it with the preview -n option: bash git clean -dn This is done to prevent accidental permanent deletion. To delete a git branch, use git branch -d.īy default, git clean will not touch directories.If you want to uncommit your changes, use git reset.If you want to remove a file from the git repository, use git rm.This command will only touch untracked files OR directories. To verify the removal of the untracked files, use the git status command.

However, be very careful, this command will delete files for REAL. If you want to proceed with the removal of the untracked files, you can use the force -f option. Using the -n option lets us preview the changes before doing the actual removal of the untracked files. To run this command, you will need to open a terminal from the location of your git repository and type: bash git clean -n Git clean is a git command that removes untracked files from a working tree.
