在 git stash
documentation ,有这样一段:
For quickly making a snapshot, you can omit "push". In this mode, non-option arguments are not allowed to prevent a misspelled subcommand from making an unwanted stash entry. The two exceptions to this are stash -p which acts as alias for stash push -p and pathspecs, which are allowed after a double hyphen -- for disambiguation.
突出显示的句子到底是什么意思?
我认为可以使用的唯一非选项参数是 <message>
和<pathspec>...
.
这是否意味着如果有人写命令 git stash -m"message"
,git 可能认为用户拼错了单词 stash
,但它仍然执行命令( git stash push
)?
谢谢。
最佳答案
据我了解,它与 git stash save
的典型行为有关。
如果你这样做
git stash save whatever you want
然后每个参数(“无论”、“你”和“想要”)都将被视为一个整体来组成 stash 消息。 (注意:存储保存
已弃用)
现在,由于 git stash Push
允许省略 push
,您以粗体引用的语句使我们刚刚看到的行为“清楚”(显然还不够)关于 git stash save 不适用。此处不允许其他非选项参数。
简而言之,我们不能做的一个例子:
git stash whatever I want
其中push
将隐含在stash
之后。
或者更具体地说(解决“拼写错误”部分):
# next command will create a new branch with the last stashed content
git stash branch myNewBranch
# and the next WOULD HAVE created a new stash entry with message "brnach myNewBranch"
# if not for the part you quoted in bold
git stash brnach myNewBranch
评论后编辑:但是最后一个拼写错误的行将被错误地拒绝,而不是无意中 stash 任何内容。
关于git stash - 防止执行拼写错误的子命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51782434/