I am moving several related projects into a monorepo, preserving every project's history.
Each of the projects in question had its own repo. Also, each project's development relied heavily on --no-ff
merges for reintegration of topic branches into the master branch.
I have experimented with shopsys/monorepo-tools and have succeeded in producing a monorepo with joined histories.
I have also found out that most of the time the topic branches were rather long and contained histories of initial implementation, review fixes, and sometimes master -> topic
merges. Naturally, it seems that this info is sort of irrelevant – only changes that made it into master
really matter.
So I have been considering rewriting the histories of these projects before merging them all into one repo. I want to achieve rewriting history from this state:
...
|
* Merge branch 'feature/XYZ'
|\
| * feature/XYZ#3 Review fixes part 2
| * feature/XYZ#2 Review fixes
| * feature/XYZ#1 Hack, hack, hack
|/
* Initial commit
To this state:
...
|
* squashed: feature/XYZ#1 + feature/XYZ#2 + feature/XYZ#3
|
* Initial commit
I want to repeat this for every merge in history. I think I have to use git filter-branch
, but I can't quite wrap my head around its multiple options yet, so I'd be really grateful if someone could nudge me in the right direction.