!镜像git存储库后出现[远程拒绝]错误

时间:2015-12-14 10:57:44

标签: git repository mirror

我关注此文档: https://help.github.com/articles/duplicating-a-repository/

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git

cd repository-to-mirror.git

git push --mirror https://github.com/exampleuser/mirrored

输出显示存储库是作为镜像推送的,但出于某种原因我也遇到了这些错误:

 ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/1/merge -> refs/pull/1/merge (deny updating a hidden ref)

这些错误是什么?我可以假设存储库已镜像了吗?

5 个答案:

答案 0 :(得分:18)

正如this issue中所提到的那样,当您镜像GitHub仓库时会发生这种情况,该仓库有拉取请求

  

参考开头' refs/pull '是由GitHub创建的合成只读引用 - 您无法更新(因此清除它们),因为它们反映了实际上可能来自其他存储库的分支 - 提交拉取请求的分支给你。

     

所以,当你推动所有真实参考时,拉动请求不会得到更新

您需要mirror a GitHub repo without their pull requests

  

只需将上面的catch-all refspec替换为两个更具体的规格,只包含所有头部和标签,但不包括拉力,所有远程拉动参考将不再进入裸镜:

fetch = +refs/heads/*:refs/heads/*
fetch = +refs/tags/*:refs/tags/*
fetch = +refs/change/*:refs/change/*

答案 1 :(得分:2)

代替

git clone -镜像

使用

git clone -裸

instructions

答案 2 :(得分:2)

(我希望这只是一个评论,但声望不足)

根据@VonC的回答,这听起来像是一个问题。

因此,当您推送所有真实引用时,提取请求不会得到更新

我看到了您要复制存储库的两种情况。

  1. 您想要完全控制的存储库的备份/副本。
  2. 您正在修改存储库的历史记录,并且需要在本地进行备份,以防您需要撤消更改。

在任何一种情况下,看来git clone --mirror是最安全的选择,因为即使您看到push中的错误,所有与非请求请求相关的内容也都已成功推送,这可以解决方案1。对于方案2,您希望这些请求请求引用作为备份的一部分。

答案 3 :(得分:1)

https://www.metaltoad.com/blog/git-push-all-branches-new-remote

找到了可行的简单解决方案
git push newremote refs/remotes/oldremote/*:refs/heads/*

git push newremote refs/remotes/oldremote/features/*:refs/heads/features/*

答案 4 :(得分:1)

完整步骤:

git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository
git push --mirror https://github.com/exampleuser/new-repository.git
相关问题