Git Push to Multiple Repositories

There is no use in having the whole ZFS pool with backups if you won’t use it for your repositories. Backup for the private repositories is trivial - just create a repo on the server and push to it. But how do we add a new repository if one already has a remote (e.g. on GitHub)?

First step is to check current remotes. This information will come in handy a bit later

git remote -v
 origin  git@github.com:medo64/QText.git (fetch)
 origin  git@github.com:medo64/QText.git (push)

Next step is to create a bare backup repository, followed by adding both current and new destination as the push URLs:

git init --bare ^^//ring/Repositories/QText.git^^
git remote set-url --add --push origin git@github.com:medo64/QText.git
git remote set-url --add --push origin ^^//ring/Repositories/QText.git^^
git push -u origin --all

Reason behind the double add is due to Git “forgetting” its default location once the first manual add is executed. Any further update will not be affected.

Now a single push command will update both repositories.