如何将Git仓库中的特定分支导入到另一个仓库?

4

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

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

我想将mylibrary.git的分支gh-pages与其历史记录导入到myorganization.github.io.git,但我不知道该如何操作。请问有哪些适当的命令?

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

2个回答

4
尝试 -
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

非常感谢。它起作用了,但可能我的问题不太明确。我想将 mylibrary.gitgh-pages 导入到 my organization.github.io.gitmaster 分支中。 - Akira Okumura

4

请按照以下步骤进行操作:

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分支,并将其合并到你从网站仓库的默认分支中。可能会有一些冲突需要解决。

我还必须使用 git pull --allow-unrelated-histories 才能使其正常工作。 - Kenneth Hoste

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接