即使删除名为ref / for / develop的远程分支,也会阻止push

时间:2017-11-03 19:37:45

标签: git gerrit

我使用带有gerrit的git 并使用命令

git push origin HEAD:refs/for/develop

通过审查推动开发分支(通过ssh连接) 不幸的是,当我在git配置文件中使用https引用远程仓库时 像这样

[remote "origin"]
url = https://

然后命令

git push origin HEAD:refs/for/develop 

将创建名称为

的分支
refs/for/develop

当然,如果有可能,那么我将

所以我通过gerrit GUI删除了分支 但是当我通过ssh

连接时仍然无法继续审核
[remote "origin"]
url = ssh://

即使

git show-ref

不要显示这个有问题的分支

来自git的反应

fatal: One or more refs/for/ names blocks change upload
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2568, received 1800 bytes, in 0.5 seconds
Bytes per second: sent 5005.8, received 3508.8
debug1: Exit status 1
fatal: Could not read from remote repository.

当我再次切换到https时 并尝试使用相同的命令只是为了检查我是否能够创建相同的分支,如果旧的被删除然后我得到错误

USER@CE19933 MINGW64 /c/repo/repo (develop)
$ git push origin HEAD:refs/for/develop
To https:/........git
 ! [rejected]        HEAD -> refs/for/develop (fetch first)
error: failed to push some refs to 'https://........git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Please make sure you have the correct access rights
and the repository exists.

这证明并非所有关于来自远程仓库的有问题分支的信息都已被删除

我也测试了这个命令

git update-ref -d refs/for/

但是从gerrit GUI删除分支后

2 个答案:

答案 0 :(得分:0)

首先,是否有其他人在这个分支机构工作,或者您是从另一个仓库开展工作?如果是这样,那么您需要先使用firebase-plugins:1.1.3将远程工作集成到本地分支。

如果您不确定那里有什么并且感到担心$storeIds = []; foreach ($products as $product) { if(!empty( $storeIds[$product['store_id']])){ //the store is taken before }else{ // new store $data['stores'][] = array( 'store_id' => $product['store_id'], 'store_name' => $product['store_name'] ); } $storeIds[$product['store_id']] = true;//save the store id } 的后果,那么您可以创建分支的副本进行实验(git pull)或者只是记下当前提交的哈希ID,以便稍后重置,如果您改变主意(git pull)。

核选项

如果没有其他人在该分支上工作而且没有其他人根据该分支创建新分支那么您可以使用git checkout -b <experiment-branch-name>告诉您确实想要应用此提交的原始服务器。 这将取代服务器上的提交,如果您有任何同事正在处理,这将导致哭泣和咬牙切齿......所以继续 极端谨慎

答案 1 :(得分:0)

我找到了解决方案。 这个问题有趣的是我们有两个域。 新旧的。我不确定这是怎么回事。我以为他们之间没有区别,那是我的错。 我们使用旧的https,后来我们添加了gerrit并切换到新域和ssh协议。 无法在这个引用相同repo的新ssh域上执行

git push origin --delete refs/for/develop
...a lot of debug logs
fatal: One or more refs/for/ names blocks change upload
debug1: channel 0: free: client-session, nchannels 
Transferred: sent 2568, received 1800 bytes, in 0.4 second
Bytes per second: sent 6997.3, received 4904.6
debug1: Exit status 1
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

但是当我将git配置更改为旧配置并且https

[remote "origin"]
url = https://

有可能

$ git push origin --delete refs/for/develop
To https:/.......git
- [deleted]         refs/for/develop

之后,我再次切换到新域和ssh协议 现在git push with refs / for是可能的。

 git push origin HEAD:refs/for/develop

从我的观点来看,它看起来像两个存储库,带有某种复制。但我不确定是否有可能。 当我发现存储库的组织方式时,我会提供更多信息。