git clean -ndX不会删除目录 [英] git clean -ndX doesn't remove directory
问题描述
和一个git仓库: 由于 但是 这是一个bug还是一个gitignore功能没有? 这意味着它不会删除手动创建的东西,除非明确忽略它。 在这种情况下,手动创建 对于 要修复这需要在git的控制下通过添加一个文件来添加 With and a git repository of: As The But Is this a bug or a some gitignore feature I don’t get?
If I add some file to My git is pretty new: This means it will not delete manual created stuff, unless it is explicitly ignored. In this case the The same is true for your To "fix" this you need to add the
这篇关于git clean -ndX不会删除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
foo /
./ quux
./quux/foo
./quux/foo/bar
./quux/foo/bar/baz
foo
被忽略,所以git假定工作目录是干净的:
%git status
#分支大师
无需提交,工作目录干净
%git clean -ndx
会删除quux /
git clean -ndX
不会打印任何内容。我预计它也会删除 quux /
。
如果我将一些文件添加到 quux
并提交它。 git clean会尝试删除 quux / foo /
,如预期那样。 我的git非常新颖: git version 1.8.3.4
。
$ git init。
$ echo foo /> .gitignore
$ git add。; git commit -am忽略
$ mkdir -p foo / bar bar / foo
$ touch foo / bar / 1 bar / foo / 1
$ git clean -ndx
将删除bar /
将删除foo /
$ git clean -ndX
将删除foo /
$
$ / code> git help clean
说:
-X
只删除Git忽略的文件。这可能对从头开始重新生成
的所有东西很有用,但保留手动创建的文件。
bar
目录并且不会显式忽略,因此它不会被删除。
quux
目录也是如此。
bar
目录:
$ touch bar / x
$ git add bar / x
$ git commit -am add\ x
$ git clean -ndX
将删除bar / foo /
会删除foo /
$
.gitignore
:
foo/
./quux
./quux/foo
./quux/foo/bar
./quux/foo/bar/baz
foo
is ignored, git assumes working directory is clean:% git status
# On branch master
nothing to commit, working directory clean
git clean -ndx
prints:% git clean -ndx
Would remove quux/
git clean -ndX
doesn't print anything. I would expect it to remove quux/
as well.quux
and commit it. Than git clean will try to remove quux/foo/
as expected.git version 1.8.3.4
.$ git init .
$ echo foo/ >.gitignore
$ git add .;git commit -am ignore
$ mkdir -p foo/bar bar/foo
$ touch foo/bar/1 bar/foo/1
$ git clean -ndx
Would remove bar/
Would remove foo/
$ git clean -ndX
Would remove foo/
$
git help clean
says: -X
Remove only files ignored by Git. This may be useful to rebuild
everything from scratch, but keep manually created files.
bar
directory is manually created and not explicitly ignored, hence it will not be deleted.quux
directory.bar
directory under control of git by adding a file:$ touch bar/x
$ git add bar/x
$ git commit -am add\ x
$ git clean -ndX
Would remove bar/foo/
Would remove foo/
$