开发者

Deleting a branch with an invalid name in Git

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.

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.

When I try and check out the branch by running: git checkout "rel_1 (Mridang-PC's 开发者_JAVA技巧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.

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.

(By the way, the branch was renamed that way by 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)

I ended up going into my .git directory running find . |xargs grep "-t" and removing lines associated with the -t from all the files

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜