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

Published:
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 git@codeberg.org:org/repo.git
$ git remote set-url --add --push mirrors git@gitlab.com:org/repo.git
$ git remote set-url --add --push mirrors git@bitbucket.org:org/repo.git

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

$ git remote -v
mirrors DISABLED (fetch)
mirrors git@codeberg.org:org/repo.git (push)
mirrors git@gitlab.com:org/repo.git (push)
mirrors git@bitbucket.org:org/repo.git (push)

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