Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么git clean--dry run显示的未跟踪文件比git status显示的要多?_Git_Github - Fatal编程技术网

为什么git clean--dry run显示的未跟踪文件比git status显示的要多?

为什么git clean--dry run显示的未跟踪文件比git status显示的要多?,git,github,Git,Github,好的,我完成了一个项目,运行了git-pull-upstream-master,git-status说工作目录是干净的。然后我从项目中运行了一些测试 现在,git状态显示 # Untracked files: # (use "git add <file>..." to include in what will be committed) # # activemodel/log/ 这些只是日志文件的目录,但我很好奇为什么actionpack/test/temp/会出现在git

好的,我完成了一个项目,运行了
git-pull-upstream-master
,git-status说工作目录是干净的。然后我从项目中运行了一些测试

现在,
git状态
显示

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   activemodel/log/
这些只是日志文件的目录,但我很好奇为什么
actionpack/test/temp/
会出现在
git clean-dry-run中,但没有出现在
git-status中

如果所有未跟踪的文件没有显示在
git状态
中,然后
git clean
会删除您没有意识到它会删除的文件,这可能会导致问题


有人知道为什么会这样吗

它们是空目录吗

Git不跟踪空目录(实际上Git根本不跟踪目录,正如您在中所看到的),因此它们不会出现在
Git状态中,但它们确实会被
Git clean-f-d
清理

这就是为什么这样的
gitclean
命令的干运行会显示一些目录,这些目录不会以常规的
git状态出现


作为旁注,这也是为什么有些人在空目录中添加占位符文件,有时按惯例称为
.gitclude
,以使Git跟踪它们。

啊,这是有道理的
activemodel/log/
有一个空的测试和开发文件,而
actionpack/test/temp
没有任何文件。它是一个空目录,因此不会显示在
git status
中。现在我明白了。谢谢
# Would remove actionpack/test/temp/
# Would remove activemodel/log/