首页 \ 问答 \ 如何从git镜像克隆中排除拉取请求(How can I exclude pull requests from git mirror clone)

如何从git镜像克隆中排除拉取请求(How can I exclude pull requests from git mirror clone)

我想镜像克隆一个Bitbucket存储库到另一个Bitbucket存储库。 我用shell脚本管理它,它执行以下操作:

git clone --mirror <sourceUrl>
git remote set-url --push origin <targetUrl>
git push --mirror

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

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 '...'

我通过使用以下解决方法调整fetch refs,从http://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html解决了问题。

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

[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 Pull和Git Push,一切都很好。

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

问题:

  • 我可以使用“git clone --config”添加所需的获取配置(在git clone执行初始获取之前)但是我可以使用“git clone”命令删除原始的fetch = +refs/*:refs/*配置吗? 这将解决最初拉取拉请求的问题
  • 拉动后是否可以从裸存储库中删除拉取请求?
  • 是否可以从推送中排除拉取请求?

I want to mirror clone a Bitbucket Repository to another Bitbucket Repository. I manage this with a shell script, which does the following:

git clone --mirror <sourceUrl>
git remote set-url --push origin <targetUrl>
git push --mirror

Now I'm getting the following error when pushing because Bitbucket does not allow to push pull requests (which are created on the Source Bitbucket):

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 '...'

I solved the Problem with a Hint from http://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html by adapting the fetch refs with the following workaround.

I created a new bare Repository and adapted the config the following way:

[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>

Then I perform a Git Pull and Git Push and everything is fine.

Nevertheless the Workaround is not a beautiful solution because creating an empty bare repository and then overwriting it is weird so I want an alternative.

Questions:

  • I can add the needed fetch Configuration with "git clone --config" (before git clone performs it's initial fetch) but can I remove the original fetch = +refs/*:refs/* Configuration also with the "git clone" Command? This would solve the problem, that the Pull Requests are pulled initially
  • Is it possible to remove the pull requests from the bare repository after the pull?
  • Is it possible to exclude the pull requests from the push?

原文:https://stackoverflow.com/questions/37985275
更新时间:2022-06-27 22:06

最满意答案

使用JOIN:

UPDATE persons AS pchild
LEFT JOIN persons as pmom ON pmom.name = 'mothersname'
LEFT JOIN persons AS pdad ON pdad.name = 'fathersname'
SET pchild.mother = pmom.personID,
    pchild.father = pdad.personID

请注意,您必须为每个外键引用单独连接。

使用变量的第二次尝试应该有效。 但您必须在单独的调用中执行每个查询。 大多数MySQL API不允许您在同一个调用中放置多个查询。


Use a JOIN:

UPDATE persons AS pchild
LEFT JOIN persons as pmom ON pmom.name = 'mothersname'
LEFT JOIN persons AS pdad ON pdad.name = 'fathersname'
SET pchild.mother = pmom.personID,
    pchild.father = pdad.personID

Notice that you have to join separately for each foreign key reference.

Your second attempt, using the variable, should work. But you have to perform each query in a separate call. Most MySQL APIs don't allow you to put multiple queries in the same call.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)