我有一个名为" R1"的存储库。该存储库包含4个项目(P1,P2,P3和P4)。
我想将P1链接到与R3相同的另一个存储库R2。如果我在Repository R1上推送代码,则应该推送所有链接的存储库(R2和R3)。
如果可以使用GitHub,请建议我。
答案 0 :(得分:1)
没有"自动同步"在Git或GitHub的回购之间。
一种可能的实现方式是:
P1
或P2
在他们自己的git repo中(推送到各自的GitHub仓库)将P1
和P2
声明为R1
,with a directive for them to follow a branch (like master)
git submodule add -b master [URL of P1] P1/
这意味着,当您在P1
或P2
中推送任何内容时,或者您需要在R1
或R2
中执行的操作是:
git submodule update --remote
git add .
git commit -m "new SHA1 for P1 or P2"
git push
R1
仅监控P1
或P2
的{{3}}(gitlinks)。
但是,这意味着您目前有更多的回购:您有R1
和R2
,您还需要P1
和P2
作为回购。