doc/user/project/repository/mirror/pull.md
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
You can use the GitLab interface to browse the content and activity of a repository, even if it isn't hosted on GitLab. Create a pull mirror to copy the branches, tags, and commits from an upstream repository to yours.
Unlike push mirrors, pull mirrors retrieve changes from an upstream (remote) repository on a scheduled basis. To prevent the mirror from diverging from the upstream repository, don't push commits directly to the downstream mirror. Push commits to the upstream repository instead. Changes in the remote repository are pulled into the GitLab repository:
UI and API updates are subject to default pull mirroring intervals of 5 minutes. This interval can be configured on GitLab Self-Managed instances.
By default, if any branch or tag on the downstream pull mirror diverges from the local repository, GitLab stops updating the branch. This prevents data loss. Deleted branches and tags in the upstream repository are not reflected in the downstream repository.
[!note] Items deleted from the downstream pull mirror repository, but still in the upstream repository, are restored upon the next pull. For example: a branch deleted only in the mirrored repository reappears after the next pull.
After you configure a GitLab repository as a pull mirror:
Prerequisites:
repo scope. If 2FA is enabled, this personal access
token serves as your GitHub password.In the top bar, select Search or go to and find your project.
Select Settings > Repository.
Expand Mirroring repositories.
Enter the Git repository URL.
[!note] To mirror the
gitlabrepository, usegitlab.com:gitlab-org/gitlab.gitorhttps://gitlab.com/gitlab-org/gitlab.git.
In Mirror direction, select Pull.
In Authentication method, select your authentication method. For more information, see authentication methods for mirrors.
Select any of the options you need:
To save the configuration, select Mirror repository.
{{< history >}}
{{< /history >}}
To always update your local branches with remote versions, even if they have diverged from the remote, select Overwrite diverged branches when you create a mirror.
[!warning] For mirrored branches, enabling this option results in the loss of local changes.
{{< history >}}
{{< /history >}}
You can configure your mirror to automatically trigger pipelines when the remote repository updates branches or tags. Before you enable this feature:
[!warning] Only enable this feature for your own projects or those with trusted maintainers.
When SSO enforcement is enabled for your group, the user who created the mirror must maintain an active SSO session or the mirror fails.
To configure mirroring without SSO session dependency, you can use the Pull mirroring API with a project access token, group access token, or personal access token for service accounts.
{{< history >}}
{{< /history >}}
Pull mirroring uses polling to detect new branches and commits added upstream, often minutes afterwards. You can notify GitLab using an API call, but the minimum interval for pull mirroring limits is still enforced.
For more information, see start the pull mirroring process for a project.
{{< history >}}
{{< /history >}}
After 14 consecutive unsuccessful retries, the mirroring process is marked as a hard failure and mirroring attempts stop. This failure is visible in either the:
To resume project mirroring, force an update.
If multiple projects are affected by this problem, such as after a long network or server outage, you can use the Rails console to identify and update all affected projects with this command:
Project.find_each do |p|
if p.import_state && p.import_state.retry_count >= 14
puts "Resetting mirroring operation for #{p.full_path}"
p.import_state.reset_retry_count
p.import_state.set_next_execution_to_now(prioritized: true)
p.import_state.save!
end
end