如何在不分叉的情况下在 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
How to duplicate a git repository on gitlab/github without forking?
提问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-repository
is 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 中有开箱即用的功能:
- Go to
Settings
->General
of existing project - Last expanded panel
Advanced
containsExport
button. Click it and then on the top of this page you can see info messageProject export started. A download link will be sent by email.
- Check email. There is following message:
- 转到
Settings
->General
现有项目 - 最后展开的面板
Advanced
包含Export
按钮。单击它,然后在此页面的顶部您可以看到信息消息Project export started. A download link will be sent by email.
- 查看电子邮件。有以下消息:
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 小时后过期。
- Click SOME_LINKand then check the
Downloads
folder - Go to
Project - Your projects
page - Click the button
New project
- Set name of your new project on
Blank project
tab - Then go to
Import project
tab - Click the button
Gitlab export
- Click
Choose file
and select previously downloaded file*.tar.gz
- Click the button
Import project
- Then you will see
Import in progress
label. - DEAL
- 单击SOME_LINK,然后检查
Downloads
文件夹 - 转到
Project - Your projects
页面 - 点击按钮
New project
- 在
Blank project
选项卡上设置新项目的名称 - 然后转到
Import project
选项卡 - 点击按钮
Gitlab export
- 单击
Choose file
并选择以前下载的文件*.tar.gz
- 点击按钮
Import project
- 然后你会看到
Import in progress
标签。 - 交易