Select Page

Script to merge multiple git repositories into a new repository

Script to merge multiple git repositories into a new repository

There are numerous ways (Submodule, Subtree) to merge multiple #GIT repositories into one new #GIT repository while keeping history.

submodule is a better fit for component-based development, where your main project depends on a fixed version of another component (repo). You keep only references in your parent repo (gitlinks, special entries in the index)

subtree is more like a system-based development, where your all repo contains everything at once, and you can modify any part.

I’ve tried a lot of them without success till I found this script https://github.com/eitch/bash_scripts/blob/master/mergeGitRepositories2.sh

While still buggy (0.2.0), I did modify it (0.2.1) and tested it to merge more than 10 #GIT repositories into one. The modified script can be downloaded at https://gist.github.com/cedricwalter/21b34178d552c077f5d2276a242872bb

The new repository will contain a folder for every merged repository

The script adds remotes for every project and then merges in every branch and tag. These are renamed to have the origin project name as a prefix

Usage: mergeGitRepositories.sh <new_project> <my_repo_urls.lst>
Where

  • <new_project> is the name of the new project to create
  • <my_repo_urls.lst> is a file contaning the URLs to the respositories which are to be merged on separate lines.

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

Categories