Skip to content

Commit e704a44

Browse files
committed
Merge branch 'tl/doc-cli-options-first'
We explain that revs come first before the pathspec among command line arguments, but did not spell out that dashed options come before other args, which has been corrected. * tl/doc-cli-options-first: git-cli.txt: clarify "options first and then args"
2 parents 2981dbe + c11f950 commit e704a44

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Documentation/gitcli.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ Many commands take revisions (most often "commits", but sometimes
1919
"tree-ish", depending on the context and command) and paths as their
2020
arguments. Here are the rules:
2121

22+
* Options come first and then args.
23+
A subcommand may take dashed options (which may take their own
24+
arguments, e.g. "--max-parents 2") and arguments. You SHOULD
25+
give dashed options first and then arguments. Some commands may
26+
accept dashed options after you have already gave non-option
27+
arguments (which may make the command ambiguous), but you should
28+
not rely on it (because eventually we may find a way to fix
29+
these ambiguity by enforcing the "options then args" rule).
30+
2231
* Revisions come first and then paths.
2332
E.g. in `git diff v1.0 v2.0 arch/x86 include/asm-x86`,
2433
`v1.0` and `v2.0` are revisions and `arch/x86` and `include/asm-x86`
@@ -72,24 +81,24 @@ you will.
7281
Here are the rules regarding the "flags" that you should follow when you are
7382
scripting Git:
7483

75-
* it's preferred to use the non-dashed form of Git commands, which means that
84+
* It's preferred to use the non-dashed form of Git commands, which means that
7685
you should prefer `git foo` to `git-foo`.
7786

78-
* splitting short options to separate words (prefer `git foo -a -b`
87+
* Splitting short options to separate words (prefer `git foo -a -b`
7988
to `git foo -ab`, the latter may not even work).
8089

81-
* when a command-line option takes an argument, use the 'stuck' form. In
90+
* When a command-line option takes an argument, use the 'stuck' form. In
8291
other words, write `git foo -oArg` instead of `git foo -o Arg` for short
8392
options, and `git foo --long-opt=Arg` instead of `git foo --long-opt Arg`
8493
for long options. An option that takes optional option-argument must be
8594
written in the 'stuck' form.
8695

87-
* when you give a revision parameter to a command, make sure the parameter is
96+
* When you give a revision parameter to a command, make sure the parameter is
8897
not ambiguous with a name of a file in the work tree. E.g. do not write
8998
`git log -1 HEAD` but write `git log -1 HEAD --`; the former will not work
9099
if you happen to have a file called `HEAD` in the work tree.
91100

92-
* many commands allow a long option `--option` to be abbreviated
101+
* Many commands allow a long option `--option` to be abbreviated
93102
only to their unique prefix (e.g. if there is no other option
94103
whose name begins with `opt`, you may be able to spell `--opt` to
95104
invoke the `--option` flag), but you should fully spell them out

0 commit comments

Comments
 (0)