我正在将一个git代码库迁移到另一个。为此,我对clone和push操作都使用了--mirror标志。
这是可以工作的,除了最后的一个失败,导致我的bash脚本失败,它看起来是孤立的拉取请求:
! [remote rejected] refs/pull/1/head -> refs/pull/1/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/1/merge -> refs/pull/1/merge (The current action can only be performed by the system.) ! [remote rejected] refs/pull/2/head -> refs/pull/2/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/3/head -> refs/pull/3/head (The current action can only be performed by the system.)
是否需要迁移拉流请求?
如何在执行git push --mirror时省略拉取请求?
我已经看到了修改配置文件的参考,但如果可能的话,我更喜欢在CLI中处理它。
发布于 2017-12-13 01:42:28
使用--mirror命令Git复制所有引用,就像通过refspec +refs/*:refs/*一样。(对于git clone,它还设置了一个获取镜像:一个裸克隆,其默认refspec是这个相同的+refs/*:refs/*,默认情况下启用修剪。)
正如你所看到的,一些Git服务器甚至拒绝对某些引用进行强制更新。特别是,GitHub为自己的目的保留了refs/pull/名称空间。
是否需要迁移拉流请求?
据我所知,在GitHub上甚至不可能做到这一点(当然,GitHub人员可能能够在他们自己的一端做到这一点)。
在执行
git push --mirror时,如何省略拉取请求?
我认为最简单的方法是在git clone --mirror步骤之后删除它们:
git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin但您也可以显式推送您关心的引用,这些引用可能只是refs/heads/和refs/tags/下的引用,也可能是refs/replace/和/或refs/notes/下的引用。
发布于 2017-12-13 01:38:30
为了避免推送拉取请求,你可以推送你想要的refs (通过命名它们),而不是让--mirror找到它们。This writeup提供了一个选项(一旦你安排好你的本地克隆):
$ git push --prune git@example.com:/new-location.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*您可能希望通过列出.git/refs (省略.git/refs/pull)在脚本中以编程方式生成ref列表,以确保您选择可能在其中的其他ref,如replacement refs或其他自定义ref。
是否需要迁移拉流请求?
我不认为你能做到。如果要从一个GitHub存储库迁移到另一个存储库,请使用the behavior you're seeing is expected
远程refs/pull/命名空间为只读。
Bitbucket命名空间是特定于GitHub的,所以如果您正在迁移其他服务(例如refs/pull/ ),那么迁移PR将需要他们的支持。Bitbucket doesn't have support for that sort of thing,以及其他可能以不同的方式实现它。
发布于 2021-07-19 18:07:15
下面的命令对我有效:
git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d所以,对我来说,完整的步骤是:
git clone --mirror https://github.com/exapmple/repository-to-mirror
cd repository-to-mirror
git remote set-url --push origin https://github.com/exampleuser/mirrored
git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d
git push --mirrorhttps://stackoverflow.com/questions/47776357
复制相似问题