How to copy a Gitlab project to another Gitlab repository?
I want to copy a GitLab project to another repository which should be completely independent from the original project.
For this reason, I tried forking the original project into another project. But inside the original project, the maintainer still can see a list of forks and knows where the other forks are maintained.
I want to have a complete copy without any link to the main project so it cannot be managed by the original project maintainer.
How can I do this?
4 Answers 4
Another option is to use Gitlab’s export/import feature.
Existing projects running on any GitLab instance or GitLab.com can be exported with all their related data and be moved into a new GitLab instance.
The difference with the other answer is that it also copies the following:
Exported contents
- Project and wiki repositories
- Project uploads
- Project configuration, excluding integrations
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities
- Design Management files and data
- LFS objects
- Issue boards
- Pipelines history
- Push Rules
So it depends on your use-case if you want to copy just the codes or if you also want to also migrate the other non-code items as listed above. The result would still be 2 separate projects (i.e. It will not appear as a fork).
The GitLab import/export button is displayed if the project import option is enabled.
To export, go to your project’s Settings > General page:

Then wait for the email with the downloadable tar.gz. file.
(On my version of Gitlab, if you click the button twice, you can download directly from the browser.)
Then to import, on Gitlab, select the New button > New Project from the top bar.
Then, select Import Project > Gitlab export.

The UI screenshots above may change on future Gitlab versions. Again, make sure to refer to your Gitlab instance’s docs pages, or check out the public one from Gitlab EE: Project import/export .
If all you need to migrate is the Git repo itself, you can clone the original project in a sandbox on your local machine, create the new project where you want it, set your new location as the remote and push there.
Notes
This answer is not specific to GitLab and will not copy Issues, MRs and other metadata. See @GinoMempin’s answer if you need to migrate a complete GitLab project.
Since this answer uses only Git itself, it will work from any Git server to any other.
The fast approach: transit via a mirror
Assuming old_url and new_url are your old and new URLs:
If your new repo was empty when you did this, it will now contain all the branches that exist in the original repo, without any connections to it.
If you also want to push all your tags to the new remote, run this command next:
Note that you might have to create an empty repo on the new server before you do the push operations, depending on your new server’s configuration.
The slower approach: transit via a regular sandbox
Some people have reported elsewhere that git clone —mirror doesn’t always work as expected. If you’re having trouble with the recipe above, you can use a regular sandbox instead:
With this approach, that git push —all will only push your main branch, because it only pushes all local branches, not all the remote tracking ones.
So checkout any branch you want to transfer to the new remote, and push it to the new remote. This is a somewhat slower process, but it also lets you control exactly what is being migrated, which can have its own benefits.
Again, you also need to push any tags you want to migrate, either all at once with git push —tags new_remote or one at a time.
Limitations
Migrating a Git repo via a clone will transfer everything that is managed by Git itself, but nothing else. If you have any MRs, issues, CI/CD, Wikis, etc, that you also want to migrate, you will have to use the export/import feature or another full migration approach.
Backup or Clone all your repositories from GitLab using this Utility
So, i was faced with the problem of taking backups to all my projects for purpose of DR. As you can expect, i had a lot of projects nested in groups and Manually cloning every one of them is just not the developer style of doing things.
Solution: A small node utility which does exactly that !
STEP 1
Copy that token and keep it handy
STEP 2
clone this project by typing
STEP 3
Follow the Readme instructions on the Repository to place the token in the right place and start the utility.
And Voila ! You just started cloning all your repositories nicely arranged in group wise folders.
Как скопировать проект с gitlab
How to copy a Gitlab project to another Gitlab repository?
I want to copy a GitLab project to another repository which should be completely independent from the original project.
For this reason, I tried forking the original project into another project. But inside the original project, the maintainer still can see a list of forks and knows where the other forks are maintained.
I want to have a complete copy without any link to the main project so it cannot be managed by the original project maintainer.
How can I do this?
4 Answers 4
Another option is to use Gitlab’s export/import feature.
Existing projects running on any GitLab instance or GitLab.com can be exported with all their related data and be moved into a new GitLab instance.
The difference with the other answer is that it also copies the following:
Exported contents
- Project and wiki repositories
- Project uploads
- Project configuration, excluding integrations
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities
- Design Management files and data
- LFS objects
- Issue boards
- Pipelines history
- Push Rules
So it depends on your use-case if you want to copy just the codes or if you also want to also migrate the other non-code items as listed above. The result would still be 2 separate projects (i.e. It will not appear as a fork).
The GitLab import/export button is displayed if the project import option is enabled.
To export, go to your project’s Settings > General page:

Then wait for the email with the downloadable tar.gz. file.
(On my version of Gitlab, if you click the button twice, you can download directly from the browser.)
Then to import, on Gitlab, select the New button > New Project from the top bar.
Then, select Import Project > Gitlab export.

The UI screenshots above may change on future Gitlab versions. Again, make sure to refer to your Gitlab instance’s docs pages, or check out the public one from Gitlab EE: Project import/export .
If all you need to migrate is the Git repo itself, you can clone the original project in a sandbox on your local machine, create the new project where you want it, set your new location as the remote and push there.
Notes
This answer is not specific to GitLab and will not copy Issues, MRs and other metadata. See @GinoMempin’s answer if you need to migrate a complete GitLab project.
Since this answer uses only Git itself, it will work from any Git server to any other.
The fast approach: transit via a mirror
Assuming old_url and new_url are your old and new URLs:
If your new repo was empty when you did this, it will now contain all the branches that exist in the original repo, without any connections to it.
If you also want to push all your tags to the new remote, run this command next:
Note that you might have to create an empty repo on the new server before you do the push operations, depending on your new server’s configuration.
The slower approach: transit via a regular sandbox
Some people have reported elsewhere that git clone —mirror doesn’t always work as expected. If you’re having trouble with the recipe above, you can use a regular sandbox instead:
With this approach, that git push —all will only push your main branch, because it only pushes all local branches, not all the remote tracking ones.
So checkout any branch you want to transfer to the new remote, and push it to the new remote. This is a somewhat slower process, but it also lets you control exactly what is being migrated, which can have its own benefits.
Again, you also need to push any tags you want to migrate, either all at once with git push —tags new_remote or one at a time.
Limitations
Migrating a Git repo via a clone will transfer everything that is managed by Git itself, but nothing else. If you have any MRs, issues, CI/CD, Wikis, etc, that you also want to migrate, you will have to use the export/import feature or another full migration approach.
Name already in use
gitlabhq / doc / api / project_import_export.md
- Go to file T
- Go to line L
- Copy path
- Copy permalink
Copy raw contents
Copy raw contents
Project import and export API (FREE)
Use the project import and export API to import and export projects using file transfers.
Before using the project import and export API, you might want to use the group import and export API.
For prerequisites for project import and export API, see:
- Prerequisites for project export.
- Prerequisites for project import.
Schedule an export
Start a new export.
The endpoint also accepts an upload hash parameter. It contains all the necessary information to upload the exported project to a web server or to any S3-compatible platform. For exports, GitLab:
- Only supports binary data file uploads to the final server.
- Sends the Content-Type: application/gzip header with upload requests. Ensure that your pre-signed URL includes this as part of the signature.
- Can take some time to complete the project export process. Make sure the upload URL doesn’t have a short expiration time and is available throughout the export process.
- Administrators can modify the maximum export file size. By default, the maximum is unlimited ( 0 ). To change this, edit max_export_size using either:
-
.
The upload[url] parameter is required if the upload parameter is present.
For uploads to Amazon S3, refer to Generating a pre-signed URL for uploading objects documentation scripts to generate the upload[url] .
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer or string | yes | The ID or URL-encoded path of the project owned by the authenticated user. |
| upload[url] | string | yes | The URL to upload the project. |
| description | string | no | Overrides the project description. |
| upload | hash | no | Hash that contains the information to upload the exported project to a web server. |
| upload[http_method] | string | no | The HTTP method to upload the exported project. Only PUT and POST methods allowed. Default is PUT . |
Get the status of export.
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer or string | yes | The ID or URL-encoded path of the project owned by the authenticated user. |
Status can be one of:
- none : No exports queued, started, finished, or being regenerated.
- queued : The request for export is received, and is in the queue to be processed.
- started : The export process has started and is in progress. It includes:
- The process of exporting.
- Actions performed on the resulting file, such as sending an email notifying the user to download the file, or uploading the exported file to a web server.
_links are only present when export has finished.
created_at is the project create timestamp, not the export start time.
Download the finished export.
Attribute Type Required Description id integer or string yes The ID or URL-encoded path of the project owned by the authenticated user. Requirement for Maintainer role instead of Developer role introduced in GitLab 16.0 and backported to GitLab 15.11.1 and GitLab 15.10.5.
Attribute Type Required Description file string yes The file to be uploaded. path string yes Name and path for new project. name string no The name of the project to be imported. Defaults to the path of the project if not provided. namespace integer or string no The ID or path of the namespace to import the project to. Defaults to the current user’s namespace. The override parameters passed take precedence over all values defined inside the export file.
To upload a file from your file system, use the —form argument. This causes cURL to post data using the header Content-Type: multipart/form-data . The file= parameter must point to a file on your file system and be preceded by @ . For example:
cURL doesn’t support posting a file from a remote server. This example imports a project using Python’s open method:
NOTE: The maximum import file size can be set by the Administrator. It defaults to 0 (unlimited). As an administrator, you can modify the maximum import file size. To do so, use the max_import_size option in the Application settings API or the Admin Area. Default modified from 50 MB to 0 in GitLab 13.8.
Import a file from a remote object storage (Beta)
Introduced in GitLab 13.12 in Beta with a flag named import_project_from_remote_file . Enabled by default.
FLAG: On self-managed GitLab, by default this feature is available. To hide the feature, ask an administrator to disable the feature flag named import_project_from_remote_file . On GitLab.com, this feature is available.
Attribute Type Required Description path string yes Name and path for the new project. url string yes URL for the file to import. name string no The name of the project to import. If not provided, defaults to the path of the project. namespace integer or string no The ID or path of the namespace to import the project to. Defaults to the current user’s namespace. overwrite boolean no Whether to overwrite a project with the same path when importing. Defaults to false . override_params Hash no Supports all fields defined in the Project API. The passed override parameters take precedence over all values defined in the export file.
The Content-Length header must return a valid number. The maximum file size is 10 GB. The Content-Type header must be application/gzip .
Import a file from AWS S3
-
in GitLab 14.9 in Beta, with a flag named import_project_from_remote_file_s3 . Disabled by default. in GitLab 14.10. in GitLab 15.11. Feature flag import_project_from_remote_file_s3 removed.
The passed override parameters take precedence over all values defined in the export file.
This example imports from an Amazon S3 bucket, using a module that connects to Amazon S3:
Get the status of an import.
Attribute Type Required Description id integer or string yes The ID or URL-encoded path of the project owned by the authenticated user. Status can be one of:
- none
- scheduled
- failed
- started
- finished
If the status is failed , it includes the import error message under import_error . If the status is failed , started or finished , the failed_relations array might be populated with any occurrences of relations that failed to import due to either:
- Unrecoverable errors.
- Retries were exhausted. A typical example: query timeouts.
NOTE: An element’s id field in failed_relations references the failure record, not the relation.
NOTE: The failed_relations array is capped to 100 items.
When importing from GitHub, the a stats field lists how many objects were already fetched from GitHub and how many were already imported:
How do I download my whole repository from GitLab?
I can’t work out how to download my entire repository for a given project. Most of the things I do seem to just download the latest snapshot, e.g.
The reason I want to know how to do this is for «recovery» purposes: accidental deletion, if my PC blew up, got stolen, etc.
There doesn’t seem to be a «forum» as such for GitLab, hence my posting here.
1 Answer 1
I can’t work out how to download my entire repository for a given project.
On GitHub, navigate to the main page of the repository.
Under the repository name, click Clone or download.

In the Clone with HTTPs section, click to copy the clone URL for the repository.

Change the current working directory to the location where you want the cloned directory to be made.
Type git clone , and then paste the URL you copied in Step 2.
Press Enter. Your local clone will be created.
Cloning a GitLab Repository

You can now edit these files locally, and use GitHub Desktop to push changes to your GitLab repository.

Notice an error? Think you can improve this documentation? Edit this Page
Project import/export (FREE)
Existing projects running on any GitLab instance or GitLab.com can be exported with all their related data and be moved into a new GitLab instance.
The GitLab import/export button is displayed if the project import option is enabled.
- Project import/export administration Rake tasks(FREE SELF)
To set up a project import/export:
- On the top bar, go to Menu > Admin > Settings > General > Visibility and access controls.
- Scroll to Import sources.
- Enable the desired Import sources.
Important notes
Note the following:
- Before you can import a project, you must export the data first. See Export a project and its data for how you can export a project through the UI.
- Imports from a newer version of GitLab are not supported. The Importing GitLab version must be greater than or equal to the Exporting GitLab version.
- Imports fail unless the import and export GitLab instances are compatible as described in the Version history.
- Exports are generated in your configured shared_path , a temporary shared directory, and are moved to your configured uploads_directory . Every 24 hours, a specific worker deletes these export files.
- Group members are exported as project members, as long as the user has a maintainer or administrator role in the group where the exported project lives.
- Project members with the Owner role are imported as Maintainers.
- Imported users can be mapped by their primary email on self-managed instances, if an administrative user (not an owner) does the import.
Otherwise, a supplementary comment is left to mention that the original author and
the MRs, notes, or issues are owned by the importer.
- For project migration imports performed over GitLab.com Groups, preserving author information is possible through a professional services engagement.
Version history
In GitLab 14.0, the JSON format is no longer supported for project and group exports. To allow for a transitional period, you can still import any JSON exports. The new format for imports and exports is NDJSON.
Starting with GitLab 13.0, GitLab can import bundles that were exported from a different GitLab deployment. This ability is limited to two previous GitLab minor releases, which is similar to our process for Security Releases.
| Current version | Can import bundles exported from |
|---|---|
| 13.0 | 13.0, 12.10, 12.9 |
| 13.1 | 13.1, 13.0, 12.10 |
Prior to 13.0 this was a defined compatibility table:
| Exporting GitLab version | Importing GitLab version |
|---|---|
| 11.7 to 12.10 | 11.7 to 12.10 |
| 11.1 to 11.6 | 11.1 to 11.6 |
| 10.8 to 11.0 | 10.8 to 11.0 |
| 10.4 to 10.7 | 10.4 to 10.7 |
| 10.3 | 10.3 |
| 10.0 to 10.2 | 10.0 to 10.2 |
| 9.4 to 9.6 | 9.4 to 9.6 |
| 9.2 to 9.3 | 9.2 to 9.3 |
| 8.17 to 9.1 | 8.17 to 9.1 |
| 8.13 to 8.16 | 8.13 to 8.16 |
| 8.12 | 8.12 |
| 8.10.3 to 8.11 | 8.10.3 to 8.11 |
| 8.10.0 to 8.10.2 | 8.10.0 to 8.10.2 |
| 8.9.5 to 8.9.11 | 8.9.5 to 8.9.11 |
| 8.9.0 to 8.9.4 | 8.9.0 to 8.9.4 |
Projects can be exported and imported only between versions of GitLab with matching Import/Export versions.
For example, 8.10.3 and 8.11 have the same Import/Export version (0.1.3) and the exports between them are compatible.
Between CE and EE
You can export projects from the Community Edition to the Enterprise Edition and vice versa. This assumes version history requirements are met.
If you’re exporting a project from the Enterprise Edition to the Community Edition, you may lose data that is retained only in the Enterprise Edition. For more information, see downgrading from EE to CE.
Exported contents
The following items are exported:
- Project and wiki repositories
- Project uploads
- Project configuration, excluding integrations
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, time tracking, and other project entities
- Design Management files and data
- LFS objects
- Issue boards
- Pipelines history
- Push Rules
- Awards
The following items are not exported:
- Build traces and artifacts
- Container registry images
- CI/CD variables
- Webhooks
- Any encrypted tokens
- Merge Request Approvers
NOTE: For more details on the specific data persisted in a project export, see the import_export.yml file.
Export a project and its data
Full project export functionality is limited to project maintainers and owners. You can configure such functionality through project settings:
To export a project and its data, follow these steps:
Go to your project’s homepage.
Click Settings in the sidebar.
Scroll down to find the Export project button:
After the export is generated, you should receive an email with a link to download the file:

Alternatively, you can come back to the project settings and download the file from there, or generate a new export. After the file is available, the page should show the Download export button:

Import the project
WARNING: Only import projects from sources you trust. If you import a project from an untrusted source, it may be possible for an attacker to steal your sensitive data.
The GitLab project import feature is the first import option when creating a new project. Click on GitLab export:

Enter your project name and URL. Then select the file you exported previously:

Click on Import project to begin importing. Your newly imported project page appears shortly.
NOTE: If use of the Internal visibility level is restricted, all imported projects are given the visibility of Private .
NOTE: The maximum import file size can be set by the Administrator, default is 0 (unlimited). As an administrator, you can modify the maximum import file size. To do so, use the max_import_size option in the Application settings API or the Admin Area UI. Default modified from 50MB to 0 in GitLab 13.8.
Project import status
You can query an import through the Project import/export API. As described in the API documentation, the query may return an import error or exceptions.
Import large projects (FREE SELF)
If you have a larger project, consider using a Rake task, as described in our developer documentation.
Rate Limits
To help avoid abuse, by default, users are rate limited to:
| Request Type | Limit |
|---|---|
| Export | 6 projects per minute |
| Download export | 1 download per group per minute |
| Import | 6 projects per minute |
GitLab.com may have different settings from the defaults.
Troubleshooting
Import workaround for large repositories
Maximum import size limitations can prevent an import from being successful. If changing the import limits is not possible, the following local workflow can be used to temporarily reduce the repository size for another import attempt.
Create a temporary working directory from the export:
Import this new, smaller file into GitLab.
In a full clone of the original repository, use git remote set-url origin <new-url> && git push —force —all to complete the import.
Update the imported repository’s branch protection rules and its default branch, and delete the temporary, smaller-… branch, and the local, temporary data.