git命令摘要中的()是什么意思? [英] What's the meaning of `()` in git command SYNOPSIS?

查看:154
本文介绍了git命令摘要中的()是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git reset简介中:

'git reset'(--patch | -p)[< tree-ish>] [-] [< paths> ...]

'git reset' (--patch | -p) [<tree-ish>] [--] [<paths>...]

我对标记的含义有疑问.

I have an issue with the markers' meaning.

我知道[]代表选项,<>代表替换.但是,()是什么意思? 如果没有|,是否仍需要括号?

I know [] stands for options, <> stands for replacement. But, what's the meaning of ()? If there's no |, are the parentheses still needed?

我没有在POSIX 实用程序约定中找到相对的线索.

I didn't find relative clues in POSIX Utility Conventions.

推荐答案

这在git的

This is covered in git's CodingGuidelines, found on their Github. It gives contributors a style guide while also describing how help options should be written. Other sources like POSIX or BSD should not be taken as authoritative, especially since they don't always conform to POSIX1. The following excerpt is near the bottom of the file:

Placeholders are spelled in lowercase and enclosed in angle brackets:
   <file>
   --sort=<key>
   --abbrev[=<n>]

Optional parts are enclosed in square brackets:
   [<extra>]
   (Zero or one <extra>.)

   --exec-path[=<path>]
   (Option with an optional argument.  Note that the "=" is inside the
   brackets.)

   [<patch>...]
   (Zero or more of <patch>.  Note that the dots are inside, not
   outside the brackets.)

Multiple alternatives are indicated with vertical bars:
   [-q | --quiet]
   [--utf8 | --no-utf8]

Parentheses are used for grouping:
   [(<rev> | <range>)...]
   (Any number of either <rev> or <range>.  Parens are needed to make
   it clear that "..." pertains to both <rev> and <range>.)

   [(-p <parent>)...]
   (Any number of option -p, each with one <parent> argument.)

   git remote set-head <name> (-a | -d | <branch>)
   (One and only one of "-a", "-d" or "<branch>" _must_ (no square
   brackets) be provided.)

And a somewhat more contrived example:
   --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
   Here "=" is outside the brackets, because "--diff-filter=" is a
   valid usage.  "*" has its own pair of brackets, because it can
   (optionally) be specified only when one or more of the letters is
   also provided.

1 :以下摘录位于文件的顶部:

1: The following excerpt is at the top of the file:

与其他项目一样,我们也有一些准则可以保留到代码中. 一般来说,对于Git来说,有一些粗略的规则是:

Like other projects, we also have some guidelines to keep to the code. For Git in general, a few rough rules are:

  • 最重要的是,我们永远不会说它在POSIX中;如果您的系统不符合您的需求,我们会很乐意忽略您的需求."我们住在 现实世界.

  • Most importantly, we never say "It's in POSIX; we'll happily ignore your needs should your system not conform to it." We live in the real world.

但是,我们经常说让我们远离该构造,甚至不在POSIX中".

However, we often say "Let's stay away from that construct, it's not even in POSIX".

尽管有上述两个规则,我们有时还是会说:尽管这不在POSIX中,但是它非常方便(使|使代码更加丰富. 可读|具有其他良好的特性),并且几乎所有 我们关心支持的平台,所以让我们使用它."

In spite of the above two rules, we sometimes say "Although this is not in POSIX, it (is so convenient | makes the code much more readable | has other good characteristics) and practically all the platforms we care about support it, so let's use it".

同样,我们生活在现实世界中,有时它是一个
判断电话,该决定更多地基于现实世界的约束 人们面对的不是纸质标准所说的那样.

Again, we live in the real world, and it is sometimes a
judgement call, the decision based more on real world constraints people face than what the paper standard says.

这篇关于git命令摘要中的()是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆