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

问题描述:

我在Gitlab/Github上已有一个存储库.我想要在相同的组下使用不同的回购名称来复制该邮件.

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.

复制存储库

要复制存储库而不进行分叉,可以运行特殊的克隆命令,然后将其镜像推送到新存储库.

Duplicating a repository

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

在复制存储库并推送到存储库的新副本或 mirror 之前,必须在GitHub/Gitlab上创建新存储库.在这些示例中,exampleuser/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.

1..打开(Win​​dows)Git Bash

1. Open (windows) Git Bash

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

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

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

2. Create a bare clone of the repository.

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

3.镜像到新的存储库.

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

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

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

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