Chemdream
Chemdream

Reputation: 627

Git Merge 2 repos follow up

This is sort of a follow up of: This question

I am trying to merge one git repo (project-a) into another (probject-b). Project b was a copy from project-a.

Specifically for this answer: If you want to merge project-a into project-b:

cd path/to/project-b
git remote add project-a path/to/project-a
git fetch project-a
git merge project-a/master # or whichever branch you want to merge
git remote remove project-a

It is VERY important that project-b's code does not merge back to project-a.

Would this solution only merge all of project-a's updates to project-b, but not merge project-b's updates back to project-a?

Upvotes: 0

Views: 182

Answers (1)

yerlilbilgin
yerlilbilgin

Reputation: 3409

The answer is yes. You added project-a as a remote and you fetched its contents but you didn't touch it. SO yes only project-b gets affected and project-a is how it was.

Specifically, if you want to merge the project-a changes to your project-b/X branch you can do this (skipping remote add/remove parts)

  git checkout X
  git merge project-a/X (or whatever branch you want to merge)

Then again the project-a/X changes came to project-b/X and project-a was not affected.

Upvotes: 1

Related Questions