3

I'm working with multiple git repositories and need to modify many of them to implement new features. So I got the idea to combine those repositories into one to reduce the administration effort and the need to create branches for each feature in all the repositories.

a       a       a       a       a       
| b     | b     | b     | b     | b     
| | c   | | e   | | c   | | c   | | c   
|/  | d |/  | d |/  | d |/  | d |/  | d 
|  /  | |  /  | |  /  | |  /  | |  /  | 
| /  /  | /  /  | /  /  | /  /  | /  /  
|/  /   |/  /   |/  /   |/  /   |/  /   
|  /    |  /    |  /    |  /    |  /    
| /     | /     | /     | /     | /     
|/      |/      |/      |/      |/      
|       |       |       |       |       
A       B       C       D       E       

I found multiple answers for merging a specific branch of one repository into a branch of other repositories like merging branches of two git repositories or using git subtree. That's not what I want to do.

I want to integrate the whole repository B with all branches and commits into A. In the end there are multiple roots in one repository with a bunch of branches each.

a               a
| b           b |
| | c       e | |
|/  | d   d |  \|
|  /  |   |  \  |
| /  /     \  \ |   ...
|/  /       \  \|
|  /         \  |
| /           \ |
|/             \|
|               |
A              (B)

Then I want to merge all branches according to their feature (a, b, d) to get all trees connected together.

        a
       / \
      /   \
     /  b  \
    /  / \  \
   /  /   \  \
  /  /     \  \
 /  /       \  \
a  /         \  a
| b     d     b |
| | c  / \  e | |
|/  | d   d |  \|
|  /  |   |  \  |
| /  /     \  \ |
|/  /       \  \|
|  /         \  |
| /           \ |
|/             \|
|               |
A              (B)

I think there must be something like a svn dump to dump all the information of repository B and load it to an orphan branch in the target repository A.

The history of each file should still be available at the end to be able to blame changes made in the separated repositories.

To make it clear: I do not want to merge branches of different repositories. I want to combine the whole repositories A and B with all the branches and the commit history.

heitho
  • 61
  • 1
  • 7
  • Possible duplicate of [How to combine two branches from two different repositories in a single repository?](https://stackoverflow.com/questions/244695/how-to-combine-two-branches-from-two-different-repositories-in-a-single-reposito) – phd Aug 30 '19 at 17:27
  • https://stackoverflow.com/search?q=%5Bgit%5D+combine+repositories – phd Aug 30 '19 at 17:27
  • Does your repositories contain same set of folder or files? – Darpan Rangari Aug 31 '19 at 09:20
  • The folder structure is identical, but with different names in the last tier – heitho Sep 02 '19 at 08:59
  • Did you figure this out? Looking for something similar for quite some time - how to combine GIT repositories with multiple branches. – Andreas Reiff Sep 15 '20 at 17:33

1 Answers1

0

Similar issue which keeps all the history and branches: Combining multiple git repositories

I good documentation can be found here https://medium.com/altcampus/how-to-merge-two-or-multiple-git-repositories-into-one-9f8a5209913f

Darpan Rangari
  • 1,494
  • 11
  • 22