repository A (already existing)
examples\
repository B (already existing)
code\
test\
尝试执行以下操作 - repo A应该是repo B的一部分。它的回购B应该是 -
repository B
code\
test\
examples\
我们希望将两个存储库分开。 用户应该能够独立地提交它们。 如果需要,可以将repo A合并到repo B,反之亦然。 我可以想到子模块,但有不同的方法来做到这一点。 我可以在repo B中克隆repo A,保留两个存储库并推送到同一个遥控器。使用分支名称作为存储库?
答案 0 :(得分:2)
没有。子模块是唯一接近它的东西,它需要单独的目录。目录中只有一个.git
目录(存储库),它包含repoA或repoB,而不是两者。
答案 1 :(得分:0)
保留单个.git
的更简单(比子模块)方式是git子树,但这也需要单独的目录。
在回购B工作
git remote add repoA url.for.A
git subtree add --prefix=examples/ repoA master
在提示中输入git subtree
会给出一个很好的使用摘要。
examples/
的提交与那些提交另外两个)这样提交日志仍然有意义。
引用git subtree
的帮助:
[TIP]
In order to keep your commit messages clean, we recommend that
people split their commits between the subtrees and the main
project as much as possible. That is, if you make a change that
affects both the library and the main application, commit it in
two pieces. That way, when you split the library commits out
later, their descriptions will still make sense. But if this
isn't important to you, it's not *necessary*. git subtree will
simply leave out the non-library-related parts of the commit
when it splits it out into the subproject later.
答案 2 :(得分:0)
您还可以查看git-repo tool以保存存储库,然后在下载后将它们移动到正确的位置。清单格式可用here。