Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to duplicate a git repository on gitlab/github without forking?

Tags:

git

github

gitlab

I've an existing repository on Gitlab / Github. I want a duplicate of that under the same group with a different repo name.

Note: Thought the answers might be similar to another question, I was not able to find the said another question by googling, I'm guessing other users might be unable to do so either.

like image 744
Dheeraj Bhaskar Avatar asked Aug 22 '17 18:08

Dheeraj Bhaskar


People also ask

Can I clone a repository without forking it?

To maintain a mirror of a repository without forking it, you can run a special clone command, then mirror-push to the new repository.


3 Answers

In gitlab there is functionality out of the box:

  1. Go to Settings -> General of existing project
  2. Last expanded panel Advanced contains Export button. Click it and then on the top of this page you can see info message Project export started. A download link will be sent by email.
  3. Check email. There is following message:

Project NAME_OF_YOUR_EXISTING_PROJECT was exported successfully.

The project export can be downloaded from: SOME_LINK

The download link will expire in 24 hours.

  1. Click SOME_LINK and then check the Downloads folder
  2. Go to Project - Your projects page
  3. Click the button New project
  4. Set name of your new project on Blank project tab
  5. Then go to Import project tab
  6. Click the button Gitlab export
  7. Click Choose file and select previously downloaded file *.tar.gz
  8. Click the button Import project
  9. Then you will see Import in progress label.
  10. DEAL
like image 159
Barabas Avatar answered Oct 06 '22 21:10

Barabas


Duplicating a repository

To duplicate a repository without forking it, you can run a special clone command, then mirror-push to the new repository.

Before you can duplicate a repository and push to your new copy, or mirror, of the repository, you must create the new repository on GitHub/Gitlab. In these examples, exampleuser/new-repository is the mirrors.

Mirroring a repository

1. Open (windows) Git Bash

You can use (mac)Terminal / (linux)Terminal as well

2. Create a bare clone of the repository.

git clone --bare https://github.com/_exampleuser_/_old-repository_.git

3. Mirror-push to the new repository.

cd _old-repository_.git
git push --mirror https://github.com/_exampleuser_/_new-repository_.git

4. Remove the temporary local repository you created in step 2.

cd ..
rm -rf _old-repository_

reference: https://help.github.com/articles/duplicating-a-repository/

like image 34
Dheeraj Bhaskar Avatar answered Oct 06 '22 21:10

Dheeraj Bhaskar


Another easiest way is ...

You can import your existing repositories by providing the Git URL:

  1. From your GitLab dashboard click New project
  2. Switch to the Import project tab
  3. Click on the Repo by URL button
  4. Fill in the “Git repository URL” and the remaining project fields
  5. Click Create project to begin the import process
  6. Once complete, you will be redirected to your newly created project

https://docs.gitlab.com/ee/user/project/import/repo_by_url.html

like image 37
aaru Avatar answered Oct 06 '22 20:10

aaru