Git

如何從 GitHub 儲存庫中“鏡像”?

  • May 22, 2013

我注意到https://github.com/apache/ant說“從 git://git.apache.org/ant.git 鏡像”(帶有連結),我也想這樣做。

https://exyr.org/2011/git-mirrors/似乎是對一般技術(基本上是一項 cron 工作)的一個很好的描述,但我遇到了一些奇怪的錯誤,我沒有看到“鏡像自” https://github.com/pdurbin/openscholar>(目的地)。我希望鏡像的來源是<https://github.com/openscholar/openscholar

這是我看到的(修剪後的)輸出:

murphy:~ pdurbin$ cd /tmp
murphy:tmp pdurbin$ git clone --mirror https://github.com/openscholar/openscholar.git
Cloning into bare repository 'openscholar.git'...
remote: Counting objects: 167069, done.
remote: Compressing objects: 100% (51806/51806), done.
remote: Total 167069 (delta 112936), reused 166304 (delta 112255)
Receiving objects: 100% (167069/167069), 82.77 MiB | 650 KiB/s, done.
Resolving deltas: 100% (112936/112936), done.
murphy:tmp pdurbin$ cd openscholar.git
murphy:openscholar.git pdurbin$ git remote add github git@github.com:pdurbin/openscholar.git
murphy:openscholar.git pdurbin$ git fetch -q && git push -q --mirror github
remote: error: hook declined to update refs/pull/1001/head
remote: error: hook declined to update refs/pull/1001/merge
(snip)
remote: error: hook declined to update refs/pull/957/head
remote: error: hook declined to update refs/pull/957/merge
To git@github.com:pdurbin/openscholar.git
* [new branch]      1017 -&gt; 1017
(snip)
* [new branch]      origin/SCHOLAR-3.x-make-1072 -&gt; origin/SCHOLAR-3.x-make-1072
* [new tag]         SCHOLAR-2-0-BETA1 -&gt; SCHOLAR-2-0-BETA1
(snip)
* [new tag]         SCHOLAR-3.1.6 -&gt; SCHOLAR-3.1.6
! [remote rejected] refs/pull/1001/head -&gt; refs/pull/1001/head (hook declined)
! [remote rejected] refs/pull/1001/merge -&gt; refs/pull/1001/merge (hook declined)
(snip)
! [remote rejected] refs/pull/957/head -&gt; refs/pull/957/head (hook declined)
! [remote rejected] refs/pull/957/merge -&gt; refs/pull/957/merge (hook declined)
error: failed to push some refs to 'git@github.com:pdurbin/openscholar.git'
murphy:openscholar.git pdurbin$ 

我相信 ceejayoz 關於 GitHub 員工需要幫助的評論是正確的。他們建議簡單地設置一個佔位符,我在https://github.com/iqss/openscholar

它沒有我最初尋找的“鏡像”,但我們可以沒有它。

關於輸出中的錯誤消息:

您可能希望從鏡像中排除拉取請求引用。我最近遇到了類似的問題,但反過來(GitHub作為源而不是目標),但它看起來可能是相關的:

http://christoph.ruegg.name/blog/2013/1/26/git-howto-mirror-a-github-repository-without-pull-refs.html

引用自:https://serverfault.com/questions/474257