- List a project’s remote mirrors
- Get a single project’s remote mirror
- Create a pull mirror
- Create a push mirror
- Update a remote mirror’s attributes
- Delete a remote mirror
Project remote mirrors API
Push mirrors defined on a project’s repository settings are called “remote mirrors”, and the state of these mirrors can be queried and modified via the remote mirror API outlined below.
List a project’s remote mirrors
Returns an Array of remote mirrors and their statuses:
Example request:
Example response:
Returns a remote mirror and its statuses:
Example request:
Example response:
Learn how to configure a pull mirror using the Projects API.
Example request:
Example response:
Example request:
Example response:
Delete a remote mirror.
Example request:
If you didn't find what you were looking for,
search the docs.
If you want help with something specific and could use community support,
.
For problems setting up or using this feature (depending on your GitLab
subscription).GET /projects/:id/remote_mirrors
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors"
[
{
"enabled": true,
"id": 101486,
"last_error": null,
"last_successful_update_at": "2020-01-06T17:32:02.823Z",
"last_update_at": "2020-01-06T17:32:02.823Z",
"last_update_started_at": "2020-01-06T17:31:55.864Z",
"only_protected_branches": true,
"keep_divergent_refs": true,
"update_status": "finished",
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}
]
url
attribute is always scrubbed of username
and password information.Get a single project’s remote mirror
GET /projects/:id/remote_mirrors/:mirror_id
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"
{
"enabled": true,
"id": 101486,
"last_error": null,
"last_successful_update_at": "2020-01-06T17:32:02.823Z",
"last_update_at": "2020-01-06T17:32:02.823Z",
"last_update_started_at": "2020-01-06T17:31:55.864Z",
"only_protected_branches": true,
"keep_divergent_refs": true,
"update_status": "finished",
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}
url
attribute is always scrubbed of username
and password information.Create a pull mirror
Create a push mirror
Attribute
Type
Required
Description
url
String
yes
The target URL to which the repository is mirrored.
enabled
Boolean
no
Determines if the mirror is enabled.
only_protected_branches
Boolean
no
Determines if only protected branches are mirrored.
keep_divergent_refs
Boolean
no
Determines if divergent refs are skipped.
curl --request POST --data "url=https://username:token@example.com/gitlab/example.git" \
--header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors"
{
"enabled": false,
"id": 101486,
"last_error": null,
"last_successful_update_at": null,
"last_update_at": null,
"last_update_started_at": null,
"only_protected_branches": false,
"keep_divergent_refs": false,
"update_status": "none",
"url": "https://*****:*****@example.com/gitlab/example.git"
}
Update a remote mirror’s attributes
Attribute
Type
Required
Description
mirror_id
Integer
yes
The remote mirror ID.
enabled
Boolean
no
Determines if the mirror is enabled.
only_protected_branches
Boolean
no
Determines if only protected branches are mirrored.
keep_divergent_refs
Boolean
no
Determines if divergent refs are skipped.
curl --request PUT --data "enabled=false" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"
{
"enabled": false,
"id": 101486,
"last_error": null,
"last_successful_update_at": "2020-01-06T17:32:02.823Z",
"last_update_at": "2020-01-06T17:32:02.823Z",
"last_update_started_at": "2020-01-06T17:31:55.864Z",
"only_protected_branches": true,
"keep_divergent_refs": true,
"update_status": "finished",
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}
Delete a remote mirror
DELETE /projects/:id/remote_mirrors/:mirror_id
Attribute
Type
Required
Description
mirror_id
Integer
yes
Remote mirror ID.
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"
Help & feedback
Docs
Edit this page
to fix an error or add an improvement in a merge request.
Create an issue
to suggest an improvement to this page.
Product
Create an issue
if there's something you don't like about this feature.
Propose functionality
by submitting a feature request.
to help shape new features.
Feature availability and product trials
to see all GitLab tiers and features, or to upgrade.
with access to all features for 30 days.
Get Help