Remove untracked local files from Git

April 4, 2015

If you have need to get rid of a bunch of files that are in your git repo but not yet tracked it can be tedious to do the job one file at a time. Git has you covered with the git clean command.

Warning: This is a permanent loss of files. Always use –dry-run to verify the action.

Remove untracked files

Remove all untracked files with

[bash]git clean -f[/bash]

Remove untracked files and directories

Remove all untracked files and also any untracked directories

[bash]git clean -f -d[/bash]

Leave a Reply

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