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

Vit*_*ian 3 git

我无法删除一个名为的远程分支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'
Run Code Online (Sandbox Code Playgroud)

UPDATE

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

注意

在远程分支是origin/origin/myFeature本地它origin/myFeature.

我知道origin通常意味着什么,但在我的情况下 - 这是分支名称的一部分.

Github没有看到这个分支.


可以请任何人解释我"幕后"发生了什么,我怎么能删除这个分支?

Ser*_*riu 9

试试这个:

git push origin :refs/heads/origin/featureBranch
Run Code Online (Sandbox Code Playgroud)

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

分支存储为小文本文件.git/refs/.当地分支机构下.git/refs/heads/,远程分支机构.git/refs/remotes/<remotename>/.master因此可以在.git/refs/heads/master和找到一个简单的分支.git/refs/remotes/origin/master,但是您的错误分支实际上将驻留在.git/refs/heads/origin/featureBranch.它不会与origin存储库中的远程分支混淆,因为它不在refs/remotes/origin/,但在下refs/heads/.

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

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