Forrest logo
back to the git tool

git-clean:tldr:16596

git-clean: Show what files would be deleted without actually deleting them.
$ git clean --dry-run
try on your machine

The command "git clean --dry-run" is used in Git to check what files and directories would be removed from the working directory and staging area if the command is run without the "--dry-run" flag.

By default, Git only tracks and manages changes to files that are being committed. However, sometimes there might be untracked files or directories that are not being managed by Git and could be unnecessary. The "git clean" command allows you to remove these untracked files and directories from your working directory and staging area, reducing clutter.

When you run "git clean --dry-run", it shows you a preview of which untracked files and directories would be removed if the command is executed without the "--dry-run" flag. This allows you to see what would be deleted and decide if you want to proceed.

The output of the command will list the untracked files and directories that Git would remove, showing their paths and names. It will also display any files and directories that would be ignored by Git's clean operation if you have specified any ignore patterns using a .gitignore file.

The "--dry-run" option is useful in ensuring that you don't accidentally delete any important files or directories. It allows you to review and verify the files that will be removed before actually executing the command.

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