Home Explore Blog CI



git

3rd chunk of `Documentation/gitcli.adoc`
cb40a12a7cfdf77938739c759d7f84c4fbf2d09333799cbb00000001000009b6
 use <n> digits to display SHA-1s
---------------------------------------------
+
Note that some subcommand (e.g. `git grep`) may behave differently
when there are things on the command line other than `-h`, but `git
subcmd -h` without anything else on the command line is meant to
consistently give the usage.

--help-all::
	Some Git commands take options that are only used for plumbing or that
	are deprecated, and such options are hidden from the default usage. This
	option gives the full list of options.


Negating options
~~~~~~~~~~~~~~~~
Options with long option names can be negated by prefixing `--no-`. For
example, `git branch` has the option `--track` which is 'on' by default. You
can use `--no-track` to override that behaviour. The same goes for `--color`
and `--no-color`.


Options trump configuration and environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When there is a configuration variable or an environment variable
that tweak the behaviour of an aspect of a Git command, and also a
command line option that tweaks the same, the command line option
overrides what the configuration and/or environment variable say.

For example, the `user.name` configuration variable is used to
specify the human-readable name used by the `git commit` command to
record the author and the committer name in a newly created commit.
The `GIT_AUTHOR_NAME` environment variable, if set, takes precedence
when deciding what author name to record.  The `--author=<author>`
command line option of the `git commit` command, when given, takes
precedence over these two sources of information.


Aggregating short options
~~~~~~~~~~~~~~~~~~~~~~~~~
Commands that support the enhanced option parser allow you to aggregate short
options. This means that you can for example use `git rm -rf` or
`git clean -fdx`.


Abbreviating long options
~~~~~~~~~~~~~~~~~~~~~~~~~
Commands that support the enhanced option parser accepts unique
prefix of a long option as if it is fully spelled out, but use this
with a caution.  For example, `git commit --amen` behaves as if you
typed `git commit --amend`, but that is true only until a later version
of Git introduces another option that shares the same prefix,
e.g. `git commit --amenity` option.


Separating argument from the option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can write the mandatory option parameter to an option as a separate
word on the command line.  That means that all the following uses work:

----------------------------

Title: Git Command-Line Options and Conventions
Summary
This section describes various aspects of Git's command-line interface, including using the --help-all option, negating options with --no-, how command-line options override configuration and environment variables, aggregating short options, abbreviating long options, and separating arguments from options.