gpt4 book ai didi

GIT - 无法从远程存储库中删除特定分支

转载 作者:太空狗 更新时间:2023-10-29 13:48:27 25 4
gpt4 key购买 nike

我无法删除名为 origin/featureBranch 的远程分支。我猜是因为分支名称以origin开头,但我不确定:

$ git branch -r | grep featureBranch
origin/origin/featureBranch

$ git push origin :origin/featureBranch

error: unable to push to unqualified destination: origin/featureBranch

The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.

error: failed to push some refs to 'git@github.com:myCompany/my-repo.git'

更新

$ git push origin :featureBranch 给出同样的错误。

注意

远程分支是origin/origin/myFeature,本地是origin/myFeature

我知道 origin 通常是什么意思,但在我的例子中 - 这是分支名称的一部分。

Github 没有看到这个分支。


任何人都可以向我解释“幕后”发生了什么,我怎样才能删除这个分支?

最佳答案

试试这个:

git push origin :refs/heads/origin/featureBranch

您始终可以通过 refs/heads/ 下的技术名称引用分支.

一个分支被存储为.git/refs/下的一个小文本文件。 .本地分支机构下.git/refs/heads/.git/refs/remotes/<remotename>/ 下的远程分支机构.一个简单的分支,如 master因此可以在 .git/refs/heads/master 找到和 .git/refs/remotes/origin/master ,但您的 buggy 分支实际上位于 .git/refs/heads/origin/featureBranch 下.它不会与 origin 上的远程分支混淆存储库,因为它不在 refs/remotes/origin/ 下, 但在 refs/heads/ 下.

在远程服务器上,origin/featureBranch branch 是服务器的本地,因此它将存储在 refs/heads/ 下.推送到给定分支时,您可以通过名称或路径来识别它,因此如果名称不起作用,只需使用以 refs 开头的完整路径即可。 .

你是怎么得到这个奇怪的分支名称的?我不能确定,因为我不知道你做了什么,但我在使用 git push --mirror 时遇到了同样的问题。 , 它会推送所有引用,包括 远程引用,因此它将创建一个 origin/branchname作为本地分支机构。

关于GIT - 无法从远程存储库中删除特定分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12192676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com