p0tta
p0tta

Reputation: 1651

Create a duplicate of a repository on Gitlab

I am trying to duplicate an existing repository. I have a project called Test and I would like to create a duplicate of it called Test1. The reason I don't just want to create another branch of it is because the new repo will have a different UI (replacing Angular with React) and don't want any branching dependencies to the old one.

I am an admin on Gitlab but I only see options to Move and Delete repo but no Copy repo. This is inside a corporate's infrastructure so I don't have access to the command line git tools but I am admin in Gitlab.

enter image description here

Upvotes: 6

Views: 6266

Answers (1)

Simon Doppler
Simon Doppler

Reputation: 2093

Clone-based approach

You could clone the repository and push it to a different remote (which you would create manually on the server):

  1. Create a new repository (here https://gitlab.example.com/user/Test1)
  2. Clone your original repository
git clone --mirror https://gitlab.example.com/user/Test
  1. Change the remote on the cloned repository:
cd Test # optionally rename the directory if you want to keep it
git remote remove origin
git remote add origin [email protected]:user/Test1
  1. Push to your new remote
git push --all origin
git push --tags origin

Web-based approach

  1. Create a temporary namespace (a group for example) or use an existing one
  2. Fork your project to the temporary namespace
  3. Remove the fork relationship
  4. Rename the forked project to Test1 (make sure you change both the path and the name)
  5. Transfer project back to original owner
  6. Remove temporary namespace (if applicable)

Upvotes: 7

Related Questions