简体   繁体   English

在 git 存储推送文档中将“-p”作为“非选项参数”包括在内是什么意思?

[英]What is meant by including "-p" as a "non-option argument" in the git stash push documentation?

The git stash push documentation states: git stash push 文档指出:

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.在此模式下,不允许使用非选项 arguments 来防止拼写错误的子命令生成不需要的存储条目。 The two exceptions to this are stash -p which acts as alias for stash push -p and pathspec elements, which are allowed after a double hyphen -- for disambiguation.这两个例外是stash -p ,它充当stash push -p和 pathspec 元素的别名,允许在双连字符后使用--以消除歧义。

However, I'm confused by the stash -p example being listed as an exception to the non-option arguments. Isn't -p an option argument?但是,我对stash -p示例被列为非选项 arguments 的例外情况感到困惑。- -p不是选项参数吗?

For instance, the following also appears to be a valid use of omitting "push", and it creates a stash with the given message:例如,以下似乎也是省略“push”的有效用法,它使用给定的消息创建一个存储:

git stash -m "some commit message"

Am I misunderstanding something here?我在这里误解了什么吗? Is this an issue with the documentation?这是文档的问题吗?

What is meant by including stash -p as an exception to disallowing the non-option arguments, when it appears to be an option argument.?当它似乎是一个选项参数时,将stash -p作为一个例外来禁止非选项 arguments 是什么意思?

A nonoption argument is, say, a filename.一个非选项参数是,比方说,一个文件名。

Suppose you have an edited file called clea .假设您有一个名为clea的已编辑文件。 Then it is forbidden to say那么禁止说

git stash clea

because, as the documentation says, we can't tell if clea is a misspelling for some subcommand such as clear .因为,正如文档所说,我们无法判断clea是否是某些子命令(例如clear )的拼写错误。 It would have been legal to say可以合法地说

git stash push clea

but Git is not about to assume you mean that.但是 Git 不会假定您是这个意思。

But if you say但如果你说

git stash -p -- clea

that's fine;没关系; you have disambiguated sufficiently, so it is just as if you had said你已经充分消除了歧义,所以就好像你说过

git stash push -p clea

and the success of the command depends merely on whether you do in fact have a file called clea .并且该命令的成功仅取决于您实际上是否有一个名为clea的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM