How to copy a Gitlab project to another Gitlab repository?

VSB picture VSB · Nov 5, 2018 · Viewed 11.3k times · Source

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?

Answer

joanis picture joanis · Nov 5, 2018

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.

PS: I tried my answer again two years later, and it appears you need git clone --mirror <old_url>, with the --mirror switch added, if you want all the branches from the original repo pushed to the new one. If the above doesn't work for you, try with --mirror.