Git 个子目录在许多存储库中复制

Git subdirectories replicated in many repositories

对于我的论文,我有一个 Git 存储库 repo_0,其中包含许多子目录。类似于:

thesis/
    .git/
    data/
    experiments/
    papers/
    algorithm_1/
    algorithm_2/

我是唯一有权访问存储库的人。但是,我想与更多人分享 algorithm_1algorithm2,以便他们最终做出贡献。

如何将 link algorithm_1/algorithm_2/ 保存到它们自己的存储库 repo_1repo_2 中,同时将它们保存在 repo_0 中?

一个天真的解决方案是从 repo0 中获取算法并维护三个存储库,但我正在寻找一个更懒惰的解决方案,其中:

最接近的解决方案是什么?

你需要的是一个子模块。

http://git-scm.com/docs/git-submodule

这是一个很好的例子,其中 submodules 很棒。您将每个存储库视为它们自己的存储库(维护三个存储库),但实际上 "soft links" 对您的 repo_0 中的特定提交到您的其他存储库。这就像子模块是远程存储库一样工作,但是您使用 repo_0.

保留本地副本

查看关于此主题的great tutorial