3

令人惊讶的是,大量的谷歌搜索没有找到明确的参考说明 Subversion 确实“允许空文件夹”。

广泛的测试似乎表明 Git不允许空文件夹,而 subversion确实允许空文件夹。

任何人都可以提供明确的答案或参考:如果 git 确实不允许空文件夹。

任何人都可以提供明确的答案或参考:如果 Subversion确实允许空文件夹。(例如,Subversion 的书实际上并没有提及空文件夹的主题,尽管这似乎是一个主要问题!)

4

3 回答 3

6

As I explained in this answer:

  • SVN is a REVISION system (it store files and directories as part of a revision, that is a "a state of the filesystem tree" (with files and directories), in order to compute deltas.
    (That means that, yes, empty directories are allowed, as they are needed for computing a delta against future revision).

revision in svn

  • Git is at its core a content tracker (originally built for managing the hundred of patches Linus Torvalds had to merge into his Linux tree).
    It only tracks content, as snapshots, in order to compare SHA1 representing said content (which is a very fast way of checking if two contents are identical or not).

git snapshot

Since an empty directory has no content, it isn't part of the snapshot.
Note that this is an implementation issue, not a fundamental git storage design problem.
See also the "Git Book" for more.

于 2013-10-06T13:33:36.670 回答
3

来自Git 维基

目前,Git 索引(暂存区)的设计只允许列出文件,并且没有人有足够的能力进行更改以允许空目录,并没有足够关心这种情况来补救它。

颠覆书

svn add

安排工作副本中的文件、目录或符号链接以添加到存储库中。

于 2013-10-06T12:07:13.073 回答
-1

顺便说一句,如果您想在结帐时创建空文件夹,您可以使用子模块来获取它们:

j8=00000001
git update-index --add --cacheinfo 160000,$j8$j8$j8$j8$j8,path/to/emptydir

其中 j8 恶作剧只是获得正确位数的一种简单方法。唯一重要的部分是 40 位 id 不是全零。Checkout 创建一个空子目录来准备位置,以便通过子模块克隆或您管理它来填充它。

于 2018-12-29T15:51:10.473 回答