Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clean inside ignored folders

Tags:

git

gitignore

I have a folder foo that is included in gitignore:

 - .gitignore  (this contains 'foo')
 - foo
    *
    *** bar

When I run git clean -f or git clean -f -x, this does not delete bar (bar is a normal file).

Is there a way to tell git to clean inside ignored folders?

like image 458
ripper234 Avatar asked Feb 16 '12 15:02

ripper234


People also ask

Does git clean remove ignored files?

The git clean command also allows removing ignored files and directories.

Does git clean respect Gitignore?

Git normally doesn't clean ignored files unless the -x flag is specified, but strangely it cleans out when configured as you did ( folder/* ). As @VonC pointed out, you should change your . gitignore -file to ignore the directory ( data/ ) rather than its contents ( data/* ).

What does git clean Fd do?

Use git clean -f -d to make sure that directories are also removed. Don't actually remove anything, just show what would be done. Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is not removed by default.


1 Answers

git clean -fdx will delete all untracked files, including directories. The -d is necessary to cause the cleaner to descend into the untracked dir.

like image 175
Borealid Avatar answered Oct 12 '22 20:10

Borealid