如何在不分叉的情况下在 gitlab/github 上复制 git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45824867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:52:29  来源:igfitidea点击:

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

gitgithubgitlab

提问by Dheeraj Bhaskar

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

我在 Gitlab/Github 上有一个现有的存储库。我想在同一组下使用不同的 repo 名称复制它。

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.

注意:认为答案可能与另一个问题类似,我无法通过谷歌搜索找到所说的另一个问题,我猜其他用户也可能无法这样做。

回答by Dheeraj Bhaskar

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-repositoryis the mirrors.

在复制存储库并推送到存储库的新副本或镜像之前,您必须在 GitHub/Gitlab 上创建新存储库。在这些例子中,exampleuser/new-repository是镜子。

Mirroring a repository

镜像仓库

1.Open (windows) Git Bash

1.打开(windows)Git Bash

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

您也可以使用 (mac)Terminal / (linux)Terminal

2.Create a bare clone of the repository.

2.创建存储库的裸克隆。

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

3.Mirror-push to the new repository.

3.镜像推送到新仓库。

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.

4.删除您在步骤 1 中创建的临时本地存储库。



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

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

回答by Barabas

In gitlab there is functionality out of the box:

在 gitlab 中有开箱即用的功能:

  1. Go to Settings-> Generalof existing project
  2. Last expanded panel Advancedcontains Exportbutton. 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:
  1. 转到Settings->General现有项目
  2. 最后展开的面板Advanced包含Export按钮。单击它,然后在此页面的顶部您可以看到信息消息Project export started. A download link will be sent by email.
  3. 查看电子邮件。有以下消息:

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.

项目 NAME_OF_YOUR_EXISTING_PROJECT 已成功导出。

可以从以下位置下载项目导出:SOME_LINK

下载链接将在 24 小时后过期。

  1. Click SOME_LINKand then check the Downloadsfolder
  2. Go to Project - Your projectspage
  3. Click the button New project
  4. Set name of your new project on Blank projecttab
  5. Then go to Import projecttab
  6. Click the button Gitlab export
  7. Click Choose fileand select previously downloaded file *.tar.gz
  8. Click the button Import project
  9. Then you will see Import in progresslabel.
  10. DEAL
  1. 单击SOME_LINK,然后检查Downloads文件夹
  2. 转到Project - Your projects页面
  3. 点击按钮 New project
  4. Blank project选项卡上设置新项目的名称
  5. 然后转到Import project选项卡
  6. 点击按钮 Gitlab export
  7. 单击Choose file并选择以前下载的文件*.tar.gz
  8. 点击按钮 Import project
  9. 然后你会看到Import in progress标签。
  10. 交易