繁体   English   中英

如何将Git存储库的特定分支导入另一个存储库?

[英]How do I import a specific branch of a Git repository to another repository?

我在GitHub上有一个组织,其中有两个存储库。 一个是C ++库,另一个是HTML存储库。

假设它们位于以下存储库中。 https://github.com/MyOrganization/mylibrary.git https://github.com/MyOrganization/myorganization.github.io.git

milibrary.gitmyorganization.github.io.git分支gh-pages milibrary.gitmyorganization.github.io.git ,并保留其历史记录,但是我不知道该怎么做。 有人可以告诉我适当的命令吗?

我的动机是将http://myorganization.github.io/MyLibrary/的主页迁移到http://myorganization.github.io/

尝试-

git clone https://github.com/MyOrganization/myorganization.github.io.git
cd myorganization.github.io.git
git remote add other https://github.com/MyOrganization/mylibrary.git
git fetch other
git checkout -b gh-pages --track other/gh_pages
git remote remove other

请执行以下步骤:

git clone https://github.com/MyOrganization/myorganization.github.io website
cd website
git pull https://github.com/MyOrganization/mylibrary.git gh-pages
git push

这将下载您的gh-pages分支并将其合并到网站存储库中的默认分支中。

您可能需要解决一些冲突。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM