Git push to multiple remotes

Like many, I develop work in a closed environment. But when a project is nearing completion I want to release it into the wild. My research needs to be supported by available code, otherwise I could have made it all up! In academic circles, published code is usually attached to a DOI (digital object identifier). Easy places to get a DOI are services like Zenodo and Figshare. Both of these sites support links from Github repos, but Github requires payment for private repos.

Our organisation has an academic licence for Bitbucket (another Git host), and also runs a local Gitlab server. We usually develop work on Bitbucket or Gitlab, but neither of these services have integration with Zenodo or Figshare. So what can we do when our projects get to a stage where we want to archive them publicly? Thankfully Git supports multiple remotes, so we can push (simultaneously) to our private and public repositories.

At the beginning of the project we set up a remote as usual:

git remote add origin

When we want to archive publicly we add a second remote, but only for push. However this overwrites our initial push location, so we can add that again:

# Add new
git remote set-url origin --push --add
# Re-add original
git remote set-url origin --push --add

An example of what we’re archiving is this code on hill farming:

Which links to this Github repo: