Merge git repositories

We have more than 20 Git repositories for the same project, but it causes lots of headaches for building. We’ve decided to merge most of them into a single one, keeping the file history when possible.

This script uses newren/git-filter-repo and as such needs Python 3.

It’s done in 3 steps:

  • clone the local repositories from d:\dev\xxx to d:\devnew\xxx using git-filter-repo with source and target parameters
  • create a new repository at d:\devnew\merged
  • merge from d:\devnew\xxx to d:\devnew\merged\xxx using git merge --allow-unrelated-histories

I’ve removed a lot of code for brievity, so maybe it won’t work out of the box, but you should get the general idea.

Next up: pushing the new repository, then migrate the developers workstations, for which I wrote another script:

Next up: migrating Jenkins jobs. With more than 170 jobs, doing it by hand is a real chore. Fortunately, you can also automate it.

Now we can version the Jenkins configs. Then we edit, and update them.