Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to join two different git repositories into one with two branches?

Tags:

git

I want to join two different git repositories into one repository with two branches. Is it possible? How?

like image 698
snezmqd4 Avatar asked Jan 05 '10 13:01

snezmqd4


People also ask

How do I merge two branches?

To do a merge (locally), git checkout the branch you want to merge INTO. Then type git merge <branch> where <branch> is the branch you want to merge FROM. Because the history of master and the history of make_function share common ancestors and don't have any divergence descendents, we get a "fast-forward" merge.

Can I merge two local branches?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.


1 Answers

Create a new repository, then add both of these repositories as remotes:

git remote add origin1 ...
git remote add origin2 ...

Fetch from both:

git fetch origin1
git fetch origin2

Create a local branch to track a branch of each remote (assuming the master):

git branch branch1 origin1/master
git branch branch2 origin2/master
like image 77
Ben James Avatar answered Nov 15 '22 21:11

Ben James