git clean:什么是“不会删除”意思? [英] git clean: What does "Would not remove" mean?

查看:239
本文介绍了git clean:什么是“不会删除”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 git clean --dry-run 时,结果有点像:

 将删除an_untracked_file 
将删除an_untracked_file_2
不会删除some_unrelated_folder /子文件夹/

无关联的文件夹被跟踪并且没有任何变化,所以我不希望git删除它们。



但是,为什么git报告不会删除对于我的项目的一些(而不是全部)正常(并且完全未触及)文件夹?



我可以告诉是什么导致git考虑,但然后决定反对,将它们删除?



git status 列表只我知道的那些未被追踪的文件。正如预期的那样。

git ls-files --other --exclude-standard 返回那些未被跟踪的文件。正如预期的那样。

git ls-files --other --exclude-standard --directory 返回那些相同的un -tracked文件,以及一些看似普通的目录。这不是我期望看到的,因为我认为 的目的 - directory 是为了 reduce ,而不是增加返回结果的数量。



现场检查意外的目录,似乎每个都是空的,除了.gitignored .svn子文件夹。也许这个因素是对的。



任何人都可以帮我理解这种行为吗?

谢谢

解决方案

默认情况下, git clean 不会删除文件夹。它告诉你,它看到一个未跟踪的文件夹,但它不会删除它。如 git clean -d -n 标志指示它也删除目录。 / p>

When I run git clean --dry-run the results are a bit like:

Would remove an_untracked_file
Would remove an_untracked_file_2
Would not remove some_unrelated_folder/subfolder/

The "unrelated" folders are tracked and have had no changes, so I would not expect git to remove them.

But, why does git report Would not remove for some, but not all, of my project's normal (and totally untouched) folders?

Can I tell what is causing git to consider, but then decide against, removing them?

git status lists only the couple of un-tracked files I know about. As expected.

git ls-files --other --exclude-standard returns those same un-tracked files. As expected.

git ls-files --other --exclude-standard --directory returns those same un-tracked files, plus a bunch of seemingly normal directories. This is not what I expected to see since I thought the purpose of --directory was to reduce, not increase the number of results returned.

Upon spot checking the unexpected directories, it seems each one is empty, except for a ".gitignore"d .svn sub-folder. Perhaps this factors in to things.

Can anyone help me understand this behavior?

Thank you

解决方案

By default, git clean doesn't remove folders. It's telling you that it sees an untracked folder, but it won't remove it. Give it the -d flag to instruct it to remove directories as well, as in git clean -d -n

这篇关于git clean:什么是“不会删除”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆