DEV Community


Discussion on: How to properly mirror a git repository

brasskazoo profile image
Will D

Hey George, thanks for this guide!

I wanted to add a couple of things though - in my scenario I'm migrating from a server to cloud, and there's a bit of transition period where we'll need to update the mirrored repo with new commits and branches

Setup the new location to always mirror on push:

git remote add --mirror=push gitcloud

Then to update the new location (assuming the cloned mirror is the origin remote):

git remote update --prune origin && git push gitcloud

As you're aware, --prune will remove any local refs not on remote, and these deletions will also be mirrored up on the push!