Git: 克隆后缺少子目录

Git: missing subdirectories after clone

我们正在为我们的版本控制系统切换到 git。 我使用 'git svn' 将我当前的 svn 存储库 "bigproject" 克隆到 git 存储库 - 我还设置了一个 cron 来同步 svn 提交到这个 git 存储库。

"bigproject" 没有定义的外部或 svn:ignore 属性 "bigproject" 有很多目录和子目录(最多 7 级深)。

src/apps/fld1/fld2/fld3/fld4/fld5    

当我检查已迁移的 git 存储库时,它似乎包含预期的所有文件夹。

在实际迁移之前,我设置了一个暂存服务器并将这个 "bigproject" 存储库推送到那里,我试图将我的构建脚本切换为使用 git 而不是 svn。

这就是我在 "git staging" 服务器上托管存储库的方式:

git clone --bare bigproject/ bigproject.git
cp -R bigproject.git /opt/git/
cd /opt/git/bigproject.git
git init --bare --shared

在构建服务器上,在我执行 git 克隆和检查后,我发现一些子目录丢失了 - 特别是在 3 层深度之后

git@mygitserver:bigproject.git

克隆后我只有

src/apps/fld1

我多次尝试重新导出裸仓库以消除任何人为错误,但我似乎无法弄清楚。

你们以前见过这个吗?

我可以看出两个可能的原因

1) 您未达到 Windows 并且已达到 PATH 长度的最大 255 个字符

2) src/apps/fld1/ 包含一些文件,而 fld2 及其所有子目录不包含任何文件。 Git 中不能添加空目录,不包含任何文件的目录被视为空目录。如果一个目录包含一个不包含任何文件的子目录,您仍然无法将其添加到git。您可以查看 Git FAQ - how to add an empty diectory。 以下是节选

Can I add empty directories?

Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.

Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.

You can say "git add " and it will add the files in there.

If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.