Suggest an editImprove this articleRefine the answer for “What does git clean do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`git clean`** removes untracked files and directories from the working tree. **Key point:** the command does not change the commit history, but it permanently deletes files, so it is usually used with a dry run first (`git clean -n`).Shown above the full answer for quick recall.Answer (EN)Image`git clean` removes **untracked files and directories** from the working tree. --- ## What counts as untracked - files that are **not added to Git** - files that are **not in any commit** - temporary files, build artifacts, logs, and so on --- ## What the command does ```bash git clean -f ``` - removes untracked files - **does not touch** committed files - **does not change history** --- ## Commonly used options ```bash git clean -n ``` Shows **what would be removed**, without removing anything (a dry run). ```bash git clean -f ``` Removes untracked files. ```bash git clean -fd ``` Removes untracked files **and directories**. ```bash git clean -fx ``` Also removes files ignored via `.gitignore`. --- ## What `git clean` does NOT do - does not remove modified but tracked files - does not undo changes in tracked files - does not affect commits or history --- ## Important `git clean` **permanently deletes files**. It is recommended to first use: ```bash git clean -n ``` --- ## Key phrasing for an interview > `git clean` removes untracked files and directories from the working tree. The command does not change the commit history, but it can lead to data loss, so it is usually used with a preview first.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.