If you ever need to merge multiple git repositories into a single repository and also keep the history, then i have just the script for you. This script will keep your branches and tags, but since tags often are called the same, the tags and branches of a repository is renamed so that the original repository name is prefixed.
If you had the following branches and tags in your project “myproject”:
Then they would become:
Further if the original repository has more than one file and/or directory in the root, then these get moved in to a sub directory so that we don’t have conflicts with other projects.
To use the project simply create a file with the list of repository URLs you want to merge, e.g.:
# Merge repositories: firstname.lastname@example.org:4treesCH/strolch-wc-inspector.git email@example.com:4treesCH/strolch-wc-auth.git firstname.lastname@example.org:4treesCH/strolch-wc-localize-behavior.git email@example.com:4treesCH/strolchjs.git firstname.lastname@example.org:4treesCH/strolch-wc-styles.git email@example.com:4treesCH/strolch.git
Then you can perform the merge using the following script as so:
./mergeGitRepositories.sh test repos.list
So here is the script: