user2002858
user2002858

Reputation: 359

How to merge a git repository into a branch of another repository

I have a github repository XXX. I want to merge into a branch of repository YYY. After the merge, YYY should have a branch named XXX. How can I do this?

Upvotes: 0

Views: 90

Answers (1)

ArkaneMoose
ArkaneMoose

Reputation: 146

The following may work.

From repository YYY, run the following:

git remote add XXX https://github.com/YourUsername/XXX.git
git fetch XXX

Now, you should have branches like XXX/master and any other branches that were in repository XXX, prefixed with XXX/.

If you want to merge, for example, XXX/master and your current branch on YYY into a new branch called merged-from-XXX, you can do this:

git checkout -b merged-from-XXX
git pull XXX master

You will be prompted to make a merge commit and resolve any conflicts if necessary.

Upvotes: 1

Related Questions