Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

I have an organization on GitHub, in which two repositories exist. One is a C++ library, and the other is an HTML repository.

Let's assume that they are located in the following repositories. https://github.com/MyOrganization/mylibrary.git https://github.com/MyOrganization/myorganization.github.io.git

I would like to import only branch gh-pages of milibrary.git to myorganization.github.io.git with its history being kept, but I do not know how to do it. Would anyone kindly tell me appropriate commands?

My motivation is to migrate the home page of http://myorganization.github.io/MyLibrary/ to http://myorganization.github.io/

like image 221
Akira Okumura Avatar asked Oct 15 '25 05:10

Akira Okumura


2 Answers

Follow the next steps:

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

This will download your gh-pages branch and merge it into your default branch from website repository.

You may have some conflicts to solve.

like image 73
Ionică Bizău Avatar answered Oct 17 '25 19:10

Ionică Bizău


Try -

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
like image 44
Harish Ved Avatar answered Oct 17 '25 19:10

Harish Ved