如何将外部存储库添加到新的git仓库中

时间:2018-06-08 00:28:56

标签: git github

MainRepo
|
|--- repoABC

MainRepo是一个git发起的回购。

MainRepo
|
| --- repoABC
|
| --- repoDEF (unclickable)
repoDEF是另一个在MainRepo中移动的git初始化repo。添加repoDEF后,我添加了git并提交了mainRepo,然后推送到origin master。

见下图:只能访问第一个文件夹。如何使第二个文件夹可访问(可单击)

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您不关心第二个仓库的历史记录,您可以在您的仓库中本地删除gitlink (SHA1 reference in the index of your main repo),删除<a class="ms-cui-ctl-large" id="SaveAndClose" onclick="return false;" href="javascript:;" mscui:controltype="Button" role="button" unselectable="on"> </a>子文件夹,然后再次添加并推送:

repoDEF/.git/

但是如果你关心repoDEF历史,那么你需要将第二个repo添加为子模块。

cd MainRepo
git rm --cached repoDEF     # no trailing /
rm -Rf repoDEF/.git
git add repoDEF
git commit -m "Import repoDEF sources"
git push
相关问题