You can
mirror
a repository to and from external sources. You can select which repository
serves as the source. Branches, tags, and commits are synced automatically.
SCP-style URLs are
not
supported. However, the work for implementing SCP-style URLs is tracked
in
this issue
.
Subscribe to the issue to follow its progress.
Several mirroring methods exist:
Push
: Mirror a repository from GitLab to another location.
Pull
: Mirror a repository from another location. Available in the Premium and Ultimate tier.
Bidirectional
mirroring is also available, but can cause conflicts.
Mirror a repository when:
The canonical version of your project has migrated to GitLab. To keep providing a
copy of your project at its previous home, configure your GitLab repository as a
push mirror
. Changes you make to your GitLab repository are copied to
the old location.
Your GitLab instance is private, but you want to open-source some projects.
You migrated to GitLab, but the canonical version of your project is somewhere else.
Configure your GitLab repository as a
pull mirror
of the other project.
Your GitLab repository pulls copies of the commits, tags, and branches of project.
They become available to use on GitLab.
Optional. To limit the number of branches mirrored, select
Mirror only protected branches
or enter a regex in
Mirror specific branches
.
Select
Mirror repository
.
If you select
SSH public key
as your authentication method, GitLab generates a
public key for your GitLab repository. You must provide this key to the non-GitLab server.
For more information, see
Get your SSH public key
.
To mirror only branches with names matching an
re2 regular expression
,
enter a regular expression into the
Mirror specific branches
field. Branches with names that
do not match the regular expression are not mirrored.
If the other repository is hosted elsewhere, add the key to
your user’s
authorized_keys
file. Paste the entire public SSH key into the
file on its own line and save it.
If you must change the key at any time, you can remove and re-add the mirror
to generate a new key. Update the other repository with the new
key to keep the mirror running.
The generated keys are stored in the GitLab database, not in the file system. Therefore,
SSH public key authentication for mirrors cannot be used in a pre-receive hook.