1. Make sure all branches touch separate files. I would strongly recommend git-filter-repo over git-filter-branch. It's way simpler to use and orders of magnitudes faster.
2. Generate the list of commits in the correct order:
git rev-list --date-order --reverse branchA BranchB BranchC > revisions.txt
3. Go to any branch and: git rebase -i --root --force-rebase
Paste the contents of revisions.txt into the sequence editor and add "p " at the bigging of every line. Run the rebase and you are done.
-----
#!/bin/bash
if [[ ! -f "$1" ]]; then
exit 1
fi
git rev-list --no-merges --date-order --reverse $(git branch -a | grep -v '*' | grep master) | awk '{print "p " $0}' > $1
exit 0
-----
Then I can just:
-----
pushd monorepo
GIT_SEQUENCE_EDITOR=../inject_reflist.sh git rebase -i --root --force-rebase
popd
-----
And off we go! Apparently there were a few branches + merges, and we have some ongoing feature branches, so I need to find a way to bring in branches other than master as well, preferably while conserving the merges as-is, instead of skipping them like I do above.