How do you delete untracked local files from your current branch?
Show what will be deleted with the
Then - beware: this will delete files - run:
If you want to also remove directories, run If you just want to remove ignored files, run If you want to remove ignored as well as non-ignored files, run Note the case difference on the If See the |
|||||||||||||||||||||
|
|
|||||
|
I am so surprised nobody mentioned this before:
That stands for interactive and you will get a quick overview of what is going to be deleted offering you the possibility to include/exclude the affected files. Overall, still faster than running the mandatory --dry-run before the real cleaning. You will have to toss in a
That being said, the extra hand holding of interactive commands can be tiring for experienced users. These days I just use the already mentioned |
|||||||||||||||||
|
If untracked directory is a git repository of its own (e.g. submodule), you need to use
|
|||||||||||||
|
I like EDIT: Also I found a way to show untracked file in a stash (e.g. |
||||
|
git-clean is what you are looking for. It is used to remove untracked files from the working tree. |
|||||
|
If needed to remove untracked files from particular subdirectory,
And combined way to delete untracked dir/files and ignored files.
after this you will have modified files only in |
|||
|
This is what I always use:
For a very large project you might want to run it a couple of times. |
||||
|
check git manual for more help |
||||
|
A better way is to use: git clean
This removes untracked files, including directories Also, replace the |
||||
|
Someone should really mention:
Am I right? |
|||
|
protected by Elenasys Jan 13 '14 at 23:49
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?
git clean
has now an interactive mode! See my answer to this other question: git 1.8.4+ – VonC Jul 23 '13 at 6:00