Gitlab: copy project to other git lab repository

2019-05-30 00:10发布

问题:

I want to copy a gitlab project to other repository which be completely independent from original project.

For this reason I tried forking original project into another project. But inside original project, maintainer still can see list of forks and knows where is other forks are maintained.

I want to have a complete copy without any link to main project so it cannot be managed by original project maintainer.

How can I do this?

回答1:

I would clone the original project in a sandbox on your local machine, create the new project where you want it, set your new gitlab location as the remote and push there.

Assuming old_url and new_url are your old and new URLs:

git clone <old_url>
cd <repo_dir_name>
git remote add new_remote <new_url>
git push --all new_remote

Assuming your new repo was empty when you did this, it will now contain all the branches and tags that exist in the original repo, without any connections to it.



回答2:

Another option is to use Gitlab's export/import feature.

The difference with the other answer is that it also copies the following:

  • Project and wiki repositories
  • Project uploads
  • Project configuration, including services
  • Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities
  • LFS objects

So it depends on your use-case if you just want to copy the codes or if you also want to migrate the other parts, configurations, etc. listed above to your other project. The result would still be 2 separate projects (ex. will not appear as a fork).

To export, go to your project's Settings > General page:

Then wait for the email with the downloadable tar.gz. file.
(On my 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 > Github export.