Mirroring repository (GitLab)

Page content

Motivation

I want to mirror GitLab repository to a bare Git repository which was hosted by Gitosis. As of Dec. 2020, GitLab Community Edition support “Push” only. “Push” means “mirror a GitLab (CE) repository to other Git repositories.”

How to set up - GitLab

  1. Allow GitLab to access outbound Otherwise, you got an error Remote mirrors url is blocked: Requests to the local network are not allowed.

“Admin” -> “Settings” -> “Network” -> “Outbound Requests” -> “Allow requests to the local network from hooks and services”

  1. Configure repository Here is a sample configuration.
  • Git repository URL: ssh://git@gitosisrepo.com/myproject.git. Of course, you can clone the URL :)
  • Mirror direction: Push
  • Authentication method: SSH publickey
  1. Push “Mirror repository”, and your configuration would be registered if you configure the URL correctly.

  2. Copy ssh pubkey by clicking the icon of click board.

  3. (Apart from GitLab) Add the public key to the destination git repository. In my case, I configured add the SSH key under ‘gitosis-admin/keydir`, and if you want to mirror to other types of Git repository, like GitHub, Bitbucket, add the SSH public key from web pages.

  4. (Optional) My case: configure gitosis-admin of the destination repository (ssh://git@gitosisrepo.com/gitosis-admin).

[group gitlab-mirrored-myproject]
members = git@mygitlab.com
writable = myproject
  1. Back to GitLab Mirroring configuration page, and click sync mark (like recycle mark.) The mirroring would start.