dee*_*eez 22 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
Run Code Online (Sandbox Code Playgroud)
输出显示存储库是作为镜像推送的,但由于某种原因我也遇到了这些错误:
! [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)
Run Code Online (Sandbox Code Playgroud)
这些错误是什么?我可以假设存储库已镜像吗?
小智 41
完整步骤:
git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository
git push --mirror https://github.com/exampleuser/new-repository.git
Run Code Online (Sandbox Code Playgroud)
Von*_*onC 20
正如本期中提到的那样,当您镜像一个向其发出拉取请求的GitHub仓库时会发生这种情况.
refs开头'
refs/pull'是由GitHub创建的合成只读引用 - 你无法更新(因此"干净")它们,因为它们反映了实际上可能来自其他存储库的分支 - 那些向你提交了pull请求的分支.因此,当您推送所有真正的引用时,拉取请求不会更新
您需要在没有拉取请求的情况下镜像GitHub仓库.
只需用两个更具体的规格替换上面的catch-all refspec,只包括所有的头部和标签,但不包括拉力,所有远程拉动参考将不再进入你的裸镜:
fetch = +refs/heads/*:refs/heads/*
fetch = +refs/tags/*:refs/tags/*
fetch = +refs/change/*:refs/change/*
Run Code Online (Sandbox Code Playgroud)
在那里找到了有效且简单的解决方案https://www.metaltoad.com/blog/git-push-all-branches-new-remote
git push newremote refs/remotes/oldremote/*:refs/heads/*
Run Code Online (Sandbox Code Playgroud)
或者
git push newremote refs/remotes/oldremote/features/*:refs/heads/features/*
Run Code Online (Sandbox Code Playgroud)