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

*爱你&永不变心* 提交于 2019-12-10 03:55:46

问题


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.


回答1:


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 1.


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




回答2:


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


来源:https://stackoverflow.com/questions/45824867/how-to-duplicate-a-git-repository-on-gitlab-github-without-forking

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!