Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge difference code changes from one repository branch to another repository branch

Tags:

git

merge

Can anyone help me with this,

My Folder structure is like this :

Repo1 [Repository]
 |- branch1 [branch]

Repo2 [Repository]
 |-branch1 [branch]

Now I need to merge file difference changes from Repo1/branch1 to Repo2/branch1

How do I do that. I am using git [bitbucket] as source control. For GUI I am using sourcetree

Thanks,

krutik

like image 577
user3239408 Avatar asked Jan 27 '14 08:01

user3239408


1 Answers

It's actually pretty easy if both "repos" are forks of the same repository. If they are truly different repositories completely, the merge gets a little messy, but is certainly possible.

The basic steps:

cd Repo2/branch1
git remote add Repo1 ../Repo1/branch1/.git
git fetch Repo1
git merge Repo1/branch1 --allow-unrelated-histories

That should trigger a regular "git merge" scenario. Even if both repos are actually 100% separate, Git will still do the merge, but won't be able to auto merge any differences between files.

like image 114
Greg Burghardt Avatar answered Sep 29 '22 18:09

Greg Burghardt