diff --git a/README.md b/README.md index d067f18..a3c5914 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). ### git - [Checkout Previous Branch](git/checkout-previous-branch.md) +- [Delete All Untracked Files](git/delete-all-untracked-files.md) - [Intent To Add](git/intent-to-add.md) - [Staging Changes Within Vim](git/staging-changes-within-vim.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) diff --git a/git/delete-all-untracked-files.md b/git/delete-all-untracked-files.md new file mode 100644 index 0000000..12f9acd --- /dev/null +++ b/git/delete-all-untracked-files.md @@ -0,0 +1,27 @@ +# Delete All Untracked Files + +Git provides a command explicitly intended for cleaning up (read: removing) +untracked files from a local copy of a repository. + +> git-clean - Remove untracked files from the working tree + +Git does want you to be explicit though and requires you to use the `-f` +flag to force it (unless otherwise configured). + +Git also gives you fine-grained control with this command by defaulting to +only deleting untracked files in the current directory. If you want +directories of untracked files to be removed as well, you'll need the `-d` +flag. + +So if you have a local repository full of files you'd like to get rid of, +just: + +```bash +$ git clean -f -d +``` + +or just: + +```bash +$ git clean -fd +```