Ryan
Ryan

Reputation: 6217

git clean directories in untracked files

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?

Upvotes: 1

Views: 593

Answers (4)

metacubed
metacubed

Reputation: 7271

Use:

git clean -xdf

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

Upvotes: 1

Ash Wilson
Ash Wilson

Reputation: 24458

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

Upvotes: 0

Arenim
Arenim

Reputation: 4237

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.

Upvotes: 2

tom.alexander
tom.alexander

Reputation: 219

You need to add them to a .gitignore file

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

Upvotes: 1

Related Questions