为什么分支名称不能在开头包含 'hash' (#) 字符?
Why can't a branch name contain the 'hash' (#) char at the begining?
这个
git checkout -b #1-my-awesome-feature
产生错误
error: switch `b' requires a value
用反斜杠转义或用引号引起来都行
git checkout -b \#1-my-awesome-feature
但是这很奇怪
git branch #1-my-awesome-feature
将不会产生任何错误,如果您检查它是否是用
创建的
git branch --all
没有分支。
如果哈希字符不在分支名称的第一个位置,分支将被创建。
git branch feature-#1
正在执行git branch
feature-#1
* master
所以我的问题是散列 (#) 字符在终端中是如何 'translated' 的,为什么它在第一位时不起作用?
谢谢!
#
表示评论开始(至少在 linux shell 中)。所以
git checkout -b #1-my-awesome-feature
变为:
git checkout -b
并抛出 b
选项需要一个值的错误。
如 here 所示,您可以通过使用 \
转义 #
或将名称放在 single/double 引号中来解决此问题:
git checkout -b \#1-my-awesome-feature
git checkout -b "#1-my-awesome-feature"
git checkout -b '#1-my-awesome-feature'
这个
git checkout -b #1-my-awesome-feature
产生错误
error: switch `b' requires a value
用反斜杠转义或用引号引起来都行
git checkout -b \#1-my-awesome-feature
但是这很奇怪
git branch #1-my-awesome-feature
将不会产生任何错误,如果您检查它是否是用
创建的git branch --all
没有分支。
如果哈希字符不在分支名称的第一个位置,分支将被创建。
git branch feature-#1
正在执行git branch
feature-#1
* master
所以我的问题是散列 (#) 字符在终端中是如何 'translated' 的,为什么它在第一位时不起作用?
谢谢!
#
表示评论开始(至少在 linux shell 中)。所以
git checkout -b #1-my-awesome-feature
变为:
git checkout -b
并抛出 b
选项需要一个值的错误。
如 here 所示,您可以通过使用 \
转义 #
或将名称放在 single/double 引号中来解决此问题:
git checkout -b \#1-my-awesome-feature
git checkout -b "#1-my-awesome-feature"
git checkout -b '#1-my-awesome-feature'