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

时间:2022-10-14 23:43:11

I've been using Dropbox to keep my source folder synced between two computers. This folder contains my source-code which I version handle with Git.

我一直在使用Dropbox来保持我的源文件夹在两台计算机之间同步。这个文件夹包含我使用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. The branch name is 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.

似乎存在文件冲突,当我进行推送时,我的Git客户端将无效分支推送到远程。分支名称为rel_1(Mridang-PC的冲突副本2011-09-16).0-alpha2。我需要删除此分支,但无法删除。广告你可以看到名称有空格和单引号。

When I try and check out the branch by running: 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.

当我尝试通过运行检查分支:git checkout“rel_1(Mridang-PC的冲突副本2011-09-16).0-alpha2”。我得到一个错误说:致命:git checkout:我们不喜欢'rel_1(Mridang-PC的冲突副本2011-09-16).0-alpha2'作为分支名称。

Is there a way I can fix this?

有没有办法解决这个问题?

Thanks.

谢谢。

2 个解决方案

#1


1  

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.

重命名该文件,你应该没问题。

#2


0  

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 . |xargs grep "-t" and removing lines associated with the -t from all the files

我最终进入运行find的.git目录。 | xargs grep“-t”并从所有文件中删除与-t关联的行

specifically ./packed-refs, ./config ( the whole section associated with it) ./into/refs

特别是./packed-refs,./config(与之相关的整个部分)./ into / refs

#1


1  

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.

重命名该文件,你应该没问题。

#2


0  

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 . |xargs grep "-t" and removing lines associated with the -t from all the files

我最终进入运行find的.git目录。 | xargs grep“-t”并从所有文件中删除与-t关联的行

specifically ./packed-refs, ./config ( the whole section associated with it) ./into/refs

特别是./packed-refs,./config(与之相关的整个部分)./ into / refs