JetBrains Space Help

Mirror a GitLab Repository

Create a synchronized copy of an external repository hosted on GitLab.

  1. Navigate to the project in which you want to create a repository.

  2. On the project sidebar, choose Repositories.

  3. On the repositories page, click New repository:

    clickNewRepository.png
  4. On the dialog window, choose Import a repository:

    createRepoForm-ExternalMirror.png
  5. Specify the following:

    • GitLab repository URL

      In GitLab terms, repository is a project. Provide the URL of your GitLab project in the following format:

      https://GitLab.com/group-name/project-name.

    • Repository name

      Give your Space mirror repository a distinctive name and optional description. The name may not necessarily match your remote GitLab repository name.

    • Select Mirror changes from external repository.

    • Authentication

      If you have administrator rights for the GitLab repository, we strongly recommend you to authenticate with a personal access token by choosing Token from the menu. In this case, Space will automatically create a webhook on the GitLab side, that will ensure instant two-way synchronization of updates.

      You can use your existing GitLab token or create a new one — just click the Get a new token button. Then paste your token into the specified field.

      If connecting via SSH, you need to have an SSH key pair (private and public) generated and stored on your local machine in the .ssh\ subdirectory. Provide the private key to Space by uploading it to the corresponding field and enter the passphrase if your key is protected with one.

      You can choose Anonymous only if no credentials are required to access your GitLab repository.

    • Synchronization settings

      Choose updating options for your mirror:

      • Sync periodically — your mirror will be synced with the remote repository and updated approximately once an hour. Actual update frequency may vary as it depends on server load.

      • Sync on git fetch — the mirror will be synced with the remote repository every time someone runs the git fetch command.

      All options can be selected.

    • Tracked branches and tags (Git refspecs) lets you mirror specific branches of the source GitLab repo, while leaving all other branches ignored.

      You can do that to fork your GitLab repository. For example, you mirror your GitLab repository's main and create local branches off of it in Space:

      +refs/heads/main:refs/heads/main

      Then you can push to your branches and keep them updated by rebasing them onto main, all without affecting the source GitLab repository.

      To mirror and sync all branches, leave this field blank!

  6. Check that all the information you entered is correct and test the connection to your GitLab repository by clicking the Test connection button.

    • If the connection is unsuccessful, make sure that the GitLab repository URL you entered is correct, and you have sufficient rights to access the repository.

    • If the connection is successful, click Create.

    A synchronized copy of your external GitLab repository will be created and added to your project.

Last modified: 27 November 2023