首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git推送--不带pull引用的镜像

git推送--不带pull引用的镜像
EN

Stack Overflow用户
提问于 2017-12-12 23:41:51
回答 3查看 3K关注 0票数 6

我正在将一个git代码库迁移到另一个。为此,我对clonepush操作都使用了--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中处理它。

EN

回答 3

Stack Overflow用户

发布于 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步骤之后删除它们:

代码语言:javascript
复制
git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin

但您也可以显式推送您关心的引用,这些引用可能只是refs/heads/refs/tags/下的引用,也可能是refs/replace/和/或refs/notes/下的引用。

票数 8
EN

Stack Overflow用户

发布于 2017-12-13 01:38:30

为了避免推送拉取请求,你可以推送你想要的refs (通过命名它们),而不是让--mirror找到它们。This writeup提供了一个选项(一旦你安排好你的本地克隆):

代码语言:javascript
复制
$ 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,以及其他可能以不同的方式实现它。

票数 6
EN

Stack Overflow用户

发布于 2021-07-19 18:07:15

下面的命令对我有效:

代码语言:javascript
复制
git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d

所以,对我来说,完整的步骤是:

代码语言:javascript
复制
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 --mirror
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47776357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档