git clean directories in untracked files

599 Views Asked by At

How can I remove directories from untracked files that aren't appearing in git clean -n? Here are my steps:

git status

...gives me:

Untracked files:
(use "git add <file>..." to include in what will be committed)

css/
../../../../../../../../site-testing/lru-cache/

I get no results from git clean -n (or git clean --dry-run).

How can I remove these directories from appearing in untracked files?

4

There are 4 best solutions below

0
On BEST ANSWER

You need to add them to a .gitignore file

http://git-scm.com/docs/gitignore

0
On

if you want to delete all the files, which are not controlled by git, use

git clean -d -f -x

if you want to ignore them -- use .gitignore file as @tom.alexander suggests.

0
On

By default, git clean operates recursively from the current working directory. Try moving to a parent directory of your working copy and invoking it from there:

cd ../../../../../../../../
git clean -n
0
On

Use:

git clean -xdf

It restores your directory (and sub-directories) to pristine condition.