If git sees a directory which contains only untracked and ignored files, clean -d should not remove that directory. --- t/t7300-clean.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index b89fd2a6a..948a455e8 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -653,4 +653,14 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir) test_path_is_dir foobar ' +test_expect_success 'git clean -d skips untracked dirs containing ignored files' ' + echo /foo/bar >.gitignore && + rm -rf foo && + mkdir -p foo && + touch foo/bar && + git clean -df && + test_path_is_file foo/bar && + test_path_is_dir foo +' + test_done -- 2.12.2