Push-only mirrors for Git Repositories View article history Edit article

Published: , Updated:
Talks about: , , and

In case you want to have push-only mirrors for your Git repository, consider adding a special mirror remote like this:

$ git remote add mirrors DISABLED
$ git remote set-url --add --push mirrors [email protected]:org/repo.git
$ git remote set-url --add --push mirrors [email protected]:org/repo.git
$ git remote set-url --add --push mirrors [email protected]:org/repo.git

The above will create a new remote called mirrors which has no fetch URL and therefore can only be pushed:

$ git remote -v
mirrors DISABLED (fetch)
mirrors [email protected]:org/repo.git (push)
mirrors [email protected]:org/repo.git (push)
mirrors [email protected]:org/repo.git (push)

Calling git push mirrors main:main will push the local main branch into all defined mirrors.