Git 个子目录在许多存储库中复制
Git subdirectories replicated in many repositories
对于我的论文,我有一个 Git 存储库 repo_0
,其中包含许多子目录。类似于:
thesis/
.git/
data/
experiments/
papers/
algorithm_1/
algorithm_2/
我是唯一有权访问存储库的人。但是,我想与更多人分享 algorithm_1
和 algorithm2
,以便他们最终做出贡献。
如何将 link algorithm_1/
和 algorithm_2/
保存到它们自己的存储库 repo_1
和 repo_2
中,同时将它们保存在 repo_0
中?
一个天真的解决方案是从 repo0
中获取算法并维护三个存储库,但我正在寻找一个更懒惰的解决方案,其中:
- 如果我在
repo_0
中提交,algorithm_n
中的更改会传播到 repo_n
和 repo_2
- 如果我在
repo_1
中提交,更改会传播到 repo_0
最接近的解决方案是什么?
你需要的是一个子模块。
这是一个很好的例子,其中 submodules 很棒。您将每个存储库视为它们自己的存储库(维护三个存储库),但实际上 "soft links" 对您的 repo_0 中的特定提交到您的其他存储库。这就像子模块是远程存储库一样工作,但是您使用 repo_0.
保留本地副本
查看关于此主题的great tutorial。
对于我的论文,我有一个 Git 存储库 repo_0
,其中包含许多子目录。类似于:
thesis/
.git/
data/
experiments/
papers/
algorithm_1/
algorithm_2/
我是唯一有权访问存储库的人。但是,我想与更多人分享 algorithm_1
和 algorithm2
,以便他们最终做出贡献。
如何将 link algorithm_1/
和 algorithm_2/
保存到它们自己的存储库 repo_1
和 repo_2
中,同时将它们保存在 repo_0
中?
一个天真的解决方案是从 repo0
中获取算法并维护三个存储库,但我正在寻找一个更懒惰的解决方案,其中:
- 如果我在
repo_0
中提交,algorithm_n
中的更改会传播到repo_n
和repo_2
- 如果我在
repo_1
中提交,更改会传播到repo_0
最接近的解决方案是什么?
你需要的是一个子模块。
这是一个很好的例子,其中 submodules 很棒。您将每个存储库视为它们自己的存储库(维护三个存储库),但实际上 "soft links" 对您的 repo_0 中的特定提交到您的其他存储库。这就像子模块是远程存储库一样工作,但是您使用 repo_0.
保留本地副本查看关于此主题的great tutorial。