netblognet
netblognet

Reputation: 2026

How to merge two code bases with Git

I'm in a tracked situation. I've got a larger project (A) on Github. Then I took a copy of the complete code, created a Git repo (B) on Bitbucket (because it can be private).

I made some changes on B which shouldn't be public and so stay on the Bitbucket repo. But the community pulled some new code on A.

How to merge the new changes on A into B?

Repo A (Github):    R1a => R2a => R3a => R4a => R5a => R6a
                            ↓                           ↓?
Repo B (Bitbucket):        R2a => R3b ===============> R4b

So at version R2a I copied the code base to Bitbucket. Then I developed R3b on Bitbucket. During and after that on Github the version R3a, R4a, R5a and R6a were developed. How to merge those changes/versions two R3b to create the merged R4b?

I know, that this won't be an automatic process because of conflicts. But how to merge from A to B exclusively?

Upvotes: 1

Views: 1979

Answers (1)

BlueSpaceCanary
BlueSpaceCanary

Reputation: 411

Git lets you add remotes. So, for example here, in a clone of B,

git remote add A https://url-to-A

Then, you can git fetch A and merge the branch you want in with

git merge A/branch 

In other words, you're doing manually for a different remote what a git pull does by default on origin/your-branch

Upvotes: 1

Related Questions