git push to multiple sites
The October 2018 day-long GitHub outage led many to consider having a live backup of their Git repos.
git push is intrinsic to Git itself.
Thus, automatic multi-site pushes are easy to configure for an arbitrarily large number of backup sites (GitHub, GitLab, Bitbucket, Dropbox, …).
This article covers the typical case where the main Git repository is on GitHub, but a public backup is desired on GitLab or similar site.
The article assumes an existing working GitHub repo cloned to your computer
We also assume SSH keys on both
Use different SSH key pairs for each site for best security.
Back up the GitHub repo
username/myprog to GitLab with every
git push automatically as in the following section.
GitHub with GitLab backup
check that the GitHub repo is setup normally on your computer:
cd myprog git remote -v
should be like:
origin https://github.invalid/username/myprog (fetch) origin ssh://github.invalid/username/myprog (push)
Create a new repo
username/myprogon GitLab or other backup site
Add the GitLab (or other) backup site:
git remote set-url origin --push --add ssh://github.invalid/username/myprog git remote set-url origin --push --add ssh://gitlab.invalid/username/myprog
Verify that BOTH
pushsites are there (in this example, github.com and gitlab.com):
git remote -v
should be like:
origin https://github.invalid/username/myprog (fetch) origin ssh://gitlab.invalid/username/myprog (push) origin ssh://github.invalid/username/myprog (push)
When pushing, you will see multiple
Everything up-to-date – one for each site you’re pushing to.