I'm trying to pull multiple repositories into a single repo. But after git pull <URL> the repositories merge and so can't identify branches that do exist in the various repositories.
CodePudding user response:
You should look at Git Submodules for this scenario. That's basically the answer (sorry it's practically link only, but it's a whole subject in its own right)
This will allow you to have multiple repositories creating one code base, and set each sub-module to its own version.
The intro to the submodules documentation is:
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
That sounds exactly like what you are trying to achieve here.
The example given on the documentation shows how to create this:
$ git submodule add https://github.com/chaconinc/DbConnector
Cloning into 'DbConnector'...
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 11 (delta 0), reused 11 (delta 0)
Unpacking objects: 100% (11/11), done.
Checking connectivity... done.
That should also create a .gitmodules file which lists the submodules being used.
