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?
The git clean command also allows removing ignored files and directories.
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/* ).
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.
git clean -fdx
will delete all untracked files, including directories. The -d
is necessary to cause the cleaner to descend into the untracked dir.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With