为什么我在使用 git mirror 命令时会出错?

问题描述

我在镜像我的存储库时遇到问题。以下命令有效:

git clone --bare https://github.com/my_username/my-repo.git
cd my-repo

还有一个我想要镜像的空存储库。该存储库归另一个人所有,但我可以访问它,因为我可以在我的 GitHub 帐户中看到它。

当我执行以下命令时,出现错误

git push --mirror https://github.com/their-username/their-repo

remote: Repository not found.
fatal: repository ‘https://github.com/their-username/their-repo/’ not found

存储库:

  1. https://github.com/my-username/my-repo(这是我的存储库,其中包含我的用户名
  2. https://github.com/their-username/their-repo(这是他们的存储库,有他们的用户名

我正在尝试将 1 镜像到 2。我可以成功克隆两个存储库

解决方法

Git 内置了镜像功能

来自你的仓库

git push --mirror https://github.com/their-username/their-repo

请注意,这将完全覆盖他们的存储库,因此您应该确保他们对此没有问题。

,

答案是:

我有只读访问权限,而不是读写访问权限。我给我的组织发送了电子邮件,他们改变了这一点,并且奏效了。