This tutorial helps demonstrate the process configuration to push your source code to multiple repositories.
Background
If a need arises to have multiple repos, then it's always better that they are in sync. Fortunately, Git allows pushing the source code to multiple repos at once.
Remote URL
Let's consider the following repo urls for the source code to be pushed. You can observe, the urls are almost identical except the domain name.
git@github.com:g33kzone/multi-repo.git
git@gitlab.com:g33kzone/multi-repo.git
Note : To prevent being asked for passwords while pushing the source code, make sure to set up SSH access for each service.
Let's have an alias created called origin to your main remote repository (i.e. Github)
git remote add origin git@github.com:g33kzone/multi-repo.git
Configure Push Remote URLs
Following commands (over the command line) will do the trick.
git remote set-url --add --push origin git@github.com:g33kzone/multi-repo.git
git remote set-url --add --push origin git@gitlab.com:g33kzone/multi-repo.git
This can be confirmed by running the following command
git remote show origin
Push Multiple Repos
Use the following command (over the command line - once) to set the upstream
git push --set-upstream origin master
Later only "git push" should also work.
Top comments (0)