无法删除带有特殊字符的git远程分支。

问题描述 投票:3回答:1

请在将此问题标记为重复之前,仔细阅读。

如果你列出分支,会出现这样的情况。

$git branch -a
  remotes/origin/feat/verify-<C3>email

分支名称是:

origin/feat/verify-√email

如果你试图从Github Dashboard上访问该分支的网址:

The github page broke into a HTTP error 400

如果你试图删除该分支:

$ git push origin --delete feat/verify-√email
error: unable to delete 'feat/verify-√email': remote ref does not exist
error: failed to push some refs to 'https://[email protected]/mataide/proak-website.git'

按模式删除

git branch -d -r $(git branch --list origin/feat/ve* -r)
error: cannot lock ref 'refs/remotes/origin/feat/verify-?email': Unable to create '/Users/marcus/Documents/Workspace/proak-website/.git/refs/remotes/origin/feat/verify-?email.lock': Illegal byte sequence
error: Error deleting remote-tracking branch 'origin/feat/verify-?email'

同样的错误,如果你尝试的名称:featverify-email.也不工作,如果你尝试删除的工具,如Sourcetree。

我只是想删除该分支,有什么帮助吗?

git command-line-interface git-branch
1个回答
0
投票

我从你的贴子中剪贴的字符是一个Unicode字符的平方根。U+221A--也请看 https:/en.wikipedia.orgwikiRadical_symbol。. 实际上,另一个 Git 中的那一个似乎是某个非Unicode字符集的代码字节-C3。 你需要让另一个 Git 以某种方式删除它。

这个 git push --delete 是个好主意,但你必须把精确的字节序列发送到另一个 Git。 我不清楚如何在任何终端会话中做到这一点。 如果您是在 MacOS 上,您可以编辑一个有正确字节序列的 shell 脚本文件:只需执行 git branch -r > /tmp/script,在一个合适的编辑器中打开该文件(例如......),删除所有不相关的行,并插入该文件。vim),删除所有不相关的行,然后插入 git push origin --delete 在剩下的一个坏名字前面。 然后运行所产生的脚本,例如。sh /tmp/script. 在没有人的手(或编辑器)接触行上的字节的情况下,原始的字节代码序列应该保持不变。

使用 git branch -d -r 即使有效,也无济于事,因为只要这个名字存在于 其他 Git。 然而,一旦你把另一个 Git 上的坏名声去掉--这可能需要外部的帮助,比如 GitHub 的人-------------------------。git fetch --prune 在你自己的版本库中,可能也不能丢弃远程跟踪的名字。 不过先试试吧)。

鉴于你的操作系统不会让你为这个名字创建锁文件,你需要手动删除正确的条目,这将是在你的 .git/packed-refs 文件。 使用一个纯文本文件编辑器(不是富文本编辑器),可以处理以换行结束的行(不是CRLF)并删除该行。

© www.soinside.com 2019 - 2024. All rights reserved.