如何删除名称以' - '开头的分支 [英] How do I delete a branch with the name starting with '-'
问题描述
为了创建一个跟踪分支,我设法创建了一个名为'-t'的本地分支。我无法删除分支,因为分支名称也是一个参数。
$ git分支-D -t
致命:需要的分行名称
转义并不有助于
$ git分支-D \ -t
致命:需要分支名称
将分支名称放在引号中也无助于
$ git分支-D-t
致命的:需要分支名称
使用git gui尝试删除分支会产生相同的错误消息。
我正在考虑从.git / refs / heads中删除'-t' - 这足够吗?还是有更多的呢?或者有没有办法可以将它从命令行中删除?
使用 -
选项
git分支-D - -t
正如您可以阅读这里
双破折号(
-
)是用于bash内置命令和许多其他命令来表示命令结束选项
Git不会将
-t
作为选项,因为它在-
之后。In an attempt to create a tracking branch I have managed to create a local branch named '-t'. I cannot delete the branch because the branch name is also a parameter. This is on a windows machine.
$ git branch -D -t fatal: branch name required
Escaping doesn't help either
$ git branch -D \-t fatal: branch name required
Placing the branch name in quotes does not help either
$ git branch -D "-t" fatal: branch name required
Using the git gui to try to delete the branch gives the same error message.
I was thinking of just deleting '-t' from .git/refs/heads - Is that enough? Or is there more to it than that? Or is there a way that can delete it from the command line?
解决方案Use the
--
optiongit branch -D -- -t
As you can read here
a double dash (
--
) is used in bash built-in commands and many other commands to signify the end of command optionsGit won't treat
-t
as an option anymore, since it comes after the--
.这篇关于如何删除名称以' - '开头的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!