简体   繁体   English

在Git中删除名称无效的分支

[英]Deleting a branch with an invalid name in Git

I've been using Dropbox to keep my source folder synced between two computers. 我一直在使用Dropbox来保持源文件夹在两台计算机之间同步。 This folder contains my source-code which I version handle with Git. 这个文件夹包含我的源代码,我使用Git版本处理。

it seems that there was a file conflict and when I did a push, my Git client, pushed an invalid branch to the remote. 似乎存在文件冲突,当我进行推送时,我的Git客户端将无效的分支推送到了远程服务器。 The branch name is rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2 . 分支名称为rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2 I need to delete this branch but an unable to do so. 我需要删除该分支,但无法删除。 Ad you can see the name has spaces and single-quote too. 您会看到广告名称中也包含空格和单引号。

When I try and check out the branch by running: git checkout "rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2" . 当我尝试通过运行以下命令git checkout "rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2"分支时: git checkout "rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2" I get an error saying: fatal: git checkout: we do not like 'rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2' as a branch name. 我收到一条错误消息: fatal: git checkout: we do not like 'rel_1 (Mridang-PC's conflicted copy 2011-09-16).0-alpha2' as a branch name.

Is there a way I can fix this? 有办法解决这个问题吗?

Thanks. 谢谢。

Look in the folder ".git/refs/heads", you will find the file which has that branch name. 在文件夹“ .git / refs / heads”中查找,您将找到具有该分支名称的文件。

(By the way, the branch was renamed that way by Dropbox). (顺便说一下,Dropbox将该分支重命名了)。

Rename that file, and you should be fine. 重命名该文件,就可以了。

I had an issue with a branch named '-t' ( which I definitely did not push to another box) 我遇到了一个名为'-t'的分支的问题(我绝对没有将其推送到另一个框)

I ended up going into my .git directory running find . 我最终进入运行find的.git目录。 |xargs grep "-t" and removing lines associated with the -t from all the files | xargs grep“ -t”并从所有文件中删除与-t关联的行

specifically ./packed-refs, ./config ( the whole section associated with it) ./into/refs 特别是./packed-refs,。/ config(与之相关的整个部分)./ into / refs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM