Forrest logo
back to the git tool

git-clean:tldr:ce0c8

git-clean: Interactively delete files that are not tracked by Git.
$ git clean -i
try on your machine

The git clean -i command in Git is used to interactively clean the working tree. It helps in removing untracked files and directories that are not part of the Git repository.

Here's what each part of the command means:

  • git clean is the core command that is used for cleaning up the working directory by removing untracked files.
  • -i or --interactive flag is used to run the clean operation in interactive mode, where you can selectively choose which untracked files to delete.

When you run git clean -i, Git will show a list of untracked files and directories and prompt you for actions to be taken. You can choose one of the following options for each untracked item:

  • clean: Deletes the selected file or directory.
  • quit: Exits the interactive clean mode.
  • help: Displays help information.
  • <path>: Deletes the specific file or directory without prompting for confirmation.
  • <enter>: Skips the current file or directory.

This interactive mode provides manual control over the deletion process, allowing you to review and select which untracked items should be removed. It helps avoid accidental deletions and gives more flexibility in cleaning up your working tree before committing or switching branches.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool