即使删除了名称为 ref/for/develop 的远程分支,推送也会被阻止
push is blocked even when remote branch with name ref/for/develop was deleted
我正在使用 git 和 gerrit
并使用命令
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 删除分支后
首先,是否还有其他人在该分支上工作,或者您是在另一个仓库中工作?如果是这样,那么您需要先使用 git pull
将远程的工作集成到本地分支中。
如果您不确定那里有什么并且担心 git pull
的后果,那么您可以创建您的分支的副本以进行实验 (git checkout -b <experiment-branch-name>
) 或只是记下如果您改变主意 (git reset --hard <hash-id>
).
,请记下当前提交的哈希 ID 以便稍后重置
核选项
如果没有其他人在该分支上工作并且没有其他人基于该分支创建新分支那么您可以使用 git push --force ...
告诉源服务器你真的,真的想要应用这个提交。 这将用你的提交替换服务器上的提交,如果你有任何同事在处理它,这将导致哭泣和咬牙切齿......所以继续极度谨慎.
我找到了解决方案。
这个问题有趣的是我们有两个域。
旧的和新的。我不确定这是如何工作的。我认为它们之间没有区别,那是我的错误。
我们使用带有 https 的旧版本,之后我们添加了 gerrit 并切换到新域和 ssh 协议。
无法在引用同一存储库的这个新 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 使用 refs/for 推送是可能的。
git push origin HEAD:refs/for/develop
目前,从我的角度来看,它看起来像是两个具有某种复制功能的存储库。但我不确定这是否可能。
当我了解存储库的组织方式时,我将提供更多信息。
我正在使用 git 和 gerrit 并使用命令
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 删除分支后
首先,是否还有其他人在该分支上工作,或者您是在另一个仓库中工作?如果是这样,那么您需要先使用 git pull
将远程的工作集成到本地分支中。
如果您不确定那里有什么并且担心 git pull
的后果,那么您可以创建您的分支的副本以进行实验 (git checkout -b <experiment-branch-name>
) 或只是记下如果您改变主意 (git reset --hard <hash-id>
).
核选项
如果没有其他人在该分支上工作并且没有其他人基于该分支创建新分支那么您可以使用 git push --force ...
告诉源服务器你真的,真的想要应用这个提交。 这将用你的提交替换服务器上的提交,如果你有任何同事在处理它,这将导致哭泣和咬牙切齿......所以继续极度谨慎.
我找到了解决方案。 这个问题有趣的是我们有两个域。 旧的和新的。我不确定这是如何工作的。我认为它们之间没有区别,那是我的错误。 我们使用带有 https 的旧版本,之后我们添加了 gerrit 并切换到新域和 ssh 协议。 无法在引用同一存储库的这个新 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 使用 refs/for 推送是可能的。
git push origin HEAD:refs/for/develop
目前,从我的角度来看,它看起来像是两个具有某种复制功能的存储库。但我不确定这是否可能。 当我了解存储库的组织方式时,我将提供更多信息。