如何从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
最满意答案
使用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.
相关问答
更多-
使用主键更新表,主键在许多子表中用作外键(update table with primary key , which is used as foreign key in many child tables)[2023-10-02]
基本上我从你的语句,UPDATE Test SET Test.id=1,NAME='XYZ'中理解的是,你正在尝试更新主键以及数据。 如果您想进行上述操作,我建议您执行以下操作。 ALGO: 第1步:使用新PK添加新记录 第2步:使用新PK更新孩子 第3步:删除旧记录。 insert into test(id,name,address) values(5,'name','address'); --where 5 is your new PK. --Updating th ... -
从错误中可以清楚地看出外键约束失败了。 请检查您的客户表,该表必须具有您尝试在结果表插入查询中插入的CustomerID ,即检查$ id的值。 你有没有为$ id分配任何值 from the error it is clear that foreign key constraint fails. Please check your customer table which must have CustomerID that you are trying to insert in results table ...
-
这将创建C ,并删除unique_field所有重复值。 CREATE TABLE C LIKE A; ALTER TABLE C ADD UNIQUE INDEX (unique_field); INSERT IGNORE INTO C SELECT * FROM A; 创建C ,可以使用A和C之间的连接来查找相应的ID,并使用它来更新B UPDATE B JOIN A ON B.foreign_key = A.id JOIN C ON C.unique_field = A.unique_field A ...
-
您的Rating表上已经有一个外键,它应该限制每个Rating行对应一个Buys行。 我认为问题必须与你的另一个目标一致,即顾客不能对同一本书进行两次评价。 关于这一点,我猜你对外键有一个误解:它们必须在目标表上是唯一的,但它们在引用方面不一定是唯一的。 要防止具有相同BookID和CustomerID组合的多个Rating行,您需要在Rating表上添加一个额外的UNIQUE约束,并命名这些列。 或者,您可以为Rating表提供由这些列组成的复合主键。 无论哪种方式,您都会有单独的约束,一个在引用表中建立 ...
-
MySQL - 在同一个表中受主键约束的外键,错误#1452(MySQL - foreign key constrained by primary key in same table, error #1452)[2022-02-18]
这将创建一个循环外键,这将防止任何插入表。 FOREIGN KEY(cat_id) REFERENCES categories(cat_id), 编辑:也许你打算把PK放在cat_parent_id ? This will create a circular foreign key, which will prevent any insertion into the table. FOREIGN KEY(cat_id) REFERENCES categories(cat_id), EDIT: ... -
我能够通过创建一个表来对其进行排序,其他3个表都链接到该表。 如果在新表中删除了一行,则会在其他表中删除生成的行。 CREATE TABLE IF NOT EXISTS `table1` ( `id` tinyint(3) NOT NULL AUTO_INCREMENT, `somefield` varchar(12) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `somefield` (`somefield`) ); CREATE TABLE ...
-
使用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 请注意,您必须为每个外键引用单独连接。 使用变量的第二次尝试应该有效。 但您必须在单独 ...
-
您正在尝试在crest.crest_recipient表中更新或插入行,该列是crest.crest_recipient列中的值 在crest_user列id中不存在 编辑 让它看起来像这样 insert crest_recipient (km,owner_id,receiver_id) values ('test',5,1) 'test',5,1是你想要的。 跳过id列。 不要指定它,不要为它提供值。 它最有可能是auto_increment PK(基本上没有别的东西可以)。 db引擎为您选择它。 指定 ...
-
不幸的是,您认为应该发生的自动删除不会发生。 您需要手动删除表B中包含您要删除的表A中的行的ID的行。 尝试将ON DELETE CASCADE添加到表B中的外键列定义中。 如果您正在使用Hibernate或其他一些ORM工具,那么它将具有一个“级联”机制,可以自动处理这个问题。 但是,由于您直接与数据库连接,因此必须记住,如果所述行的ID作为外键存在于任何其他表中,则无法删除行(在您的情况下,A的主键存在于B)中的一些行。 除非您指定ON DELETE CASCADE属性。 Unfortunately, ...
-
你没有那个特殊的ID在你的角色表上不可用。 首先插入字符表id并将该id用作queststatus表上的外键。 要么 从queststatus中删除外键引用。 You didn't have that particular id is not available on your characters table. First you insert characters table id and used that id as a foreign key on queststatus table. Or Re ...