Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git merge different repositories?

Tags:

git

git-svn

I've been using SVN for all my projects. Sometimes project B is originating as a copy from project A. When project A has a generic change, I can use svn merge A within directory B and it will merge those changes.

Now, if I wanted to use git. I don't like having all my projects in the same repository since I then have to clone everything and can't pick just one project like in SVN. But having one repository for each project, how do I go about doing the same like I did earlier with SVN?

The question is: What's the best way to structure it if I want several subprojects that really all relates to one original project and to keep them in sync? And that I also want to be able to check them out separately

like image 546
baloo Avatar asked Jun 01 '10 12:06

baloo


People also ask

Can I merge two git repositories?

Combining two git repositories. Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things: preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location.

How do I merge two git repository and keep history?

To combine two separate Git repositories into one, add the repository to merge in as a remote to the repository to merge into. Then, combine their histories by merging while using the --allow-unrelated-histories command line option.


1 Answers

If you have two projects, proj1 and proj2 and want to merge changes of proj1 into proj2, you would do it like this:

# in proj2: git remote add proj1 path/to/proj1 git fetch proj1 git merge proj1/master # or whichever branch you want to merge 

I believe this does the same thing as what you were doing with SVN.

like image 175
Olivier Verdier Avatar answered Sep 20 '22 05:09

Olivier Verdier