首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从git镜像克隆中排除拉请求?

如何从git镜像克隆中排除拉请求?
EN

Stack Overflow用户
提问于 2016-06-23 07:47:16
回答 1查看 6.2K关注 0票数 11

我想将Bitbucket存储库镜像为另一个Bitbucket存储库。我使用一个shell脚本来管理它,它执行以下操作:

代码语言:javascript
复制
git clone --mirror <sourceUrl>
git remote set-url --push origin <targetUrl>
git push --mirror

现在,我在推送时得到了以下错误,因为Bitbucket不允许推送拉请求(源Bitbucket上创建的请求):

代码语言:javascript
复制
remote: You are attempting to update refs that are reserved for Bitbucket's pull
remote: request functionality. Bitbucket manages these refs automatically, and they may
remote: not be updated by users.
remote:
remote: Rejected refs:
remote:         refs/pull-requests/21/from
remote:         refs/pull-requests/23/from
remote:         refs/pull-requests/23/merge
remote:         refs/pull-requests/24/from
remote:         refs/pull-requests/24/merge
To ...
 ! [remote rejected] refs/pull-requests/21/from -> refs/pull-requests/21/from (pre-receive hook declined)
 ! [remote rejected] refs/pull-requests/23/from -> refs/pull-requests/23/from (pre-receive hook declined)
 ! [remote rejected] refs/pull-requests/23/merge -> refs/pull-requests/23/merge (pre-receive hook declined)
 ! [remote rejected] refs/pull-requests/24/from -> refs/pull-requests/24/from (pre-receive hook declined)
 ! [remote rejected] refs/pull-requests/24/merge -> refs/pull-requests/24/merge (pre-receive hook declined)
error: failed to push some refs to '...'

通过使用下面的解决方法,我用http://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html的提示解决了这个问题。

我创建了一个新的bare存储库,并以以下方式调整了配置:

代码语言:javascript
复制
[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
[remote "origin"]
    fetch = +refs/heads/*:refs/heads/*
    fetch = +refs/tags/*:refs/tags/*
    url = <sourceUrl>
    mirror = true
    pushurl = <targetUrl>

然后我执行吉特拉和吉特推,一切都很好。

尽管如此,解决方法并不是一个漂亮的解决方案,因为创建一个空的裸存储库,然后覆盖它是很奇怪的,所以我想要一个替代方案。

问题:

  • 我可以使用"git克隆-配置“添加所需的获取配置(在git克隆执行它的初始提取之前),但是我可以使用"git克隆”命令删除原始的fetch = +refs/*:refs/*配置吗?这将解决问题,即最初的拉请求是被拉出的。
  • 是否有可能在拉完后从裸存储库中删除拉请求?
  • 是否可以将拉请求排除在推送之外?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-29 07:50:38

多亏了伊凡。

他的命令解决了我的问题。我只需将"-r“参数添加到xargs中,就可以对空grep做出反应:

代码语言:javascript
复制
git show-ref | cut -d' ' -f2 | grep 'pull-request' | xargs -r -L1 git update-ref -d
票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37985275

复制
相关文章

相似问题

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