Some time ago I had some projects which I wanted to combine in one big project and keep history for all of them. This can be done following to this article. But if I’ll use this solution in result I’ll have more than one tails (how it illustrated in picture below).
1 2 3 4 5 6 7 8 9 10 |
|
But I wanted to make repository structure as on picture below:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
After some hours with console magic I found solution, and I want to share it.
I decided to modify history to avoid possible merge conflicts. I moved all files in each project to appropriate subfolder (named as project). To do this we needs to export patch and modify it to change pathes.
1 2 3 4 5 6 7 8 9 10 |
|
For each of projects we need to make some steps (enough to change PROJECT
variable)
If you want move projects to named branches instead of multiply default branches you needs prepare following commands which adds branch name information to patch:
1 2 |
|
Now we have patches made from all projects we can combine them. First initialize aggregate repository and import oldest project of all.
1 2 |
|
For other project we need do following steps:
- Update aggregate project to revision which will be parent for appropriate project
- Import patch (don’t forget
--import-branch
key if you using named branches) - Merge branches
- Repeat it for other patches
This approach illustrated below. If you not using named branches you can use these simple steps:
1 2 3 |
|
If you using named branches your way will more complicated:
1 2 3 4 5 6 7 |
|
I’ve created script which can help to automate first part of this article:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
I’ll glad if this article will useful for someone. Comments are welcome.