former, but with the latter
you will.
* Just as the filesystem '.' (period) refers to the current directory,
using a '.' as a repository name in Git (a dot-repository) is a relative
path and means your current repository.
Here are the rules regarding the "flags" that you should follow when you are
scripting Git:
* Splitting short options to separate words (prefer `git foo -a -b`
to `git foo -ab`, the latter may not even work).
* When a command-line option takes an argument, use the 'stuck' form. In
other words, write `git foo -oArg` instead of `git foo -o Arg` for short
options, and `git foo --long-opt=Arg` instead of `git foo --long-opt Arg`
for long options. An option that takes optional option-argument must be
written in the 'stuck' form.
* Despite the above suggestion, when Arg is a path relative to the
home directory of a user, e.g. `~/directory/file` or `~u/d/f`, you
may want to use the separate form, e.g. `git foo --file ~/mine`,
not `git foo --file=~/mine`. The shell will expand `~/` in the
former to your home directory, but most shells keep the tilde in
the latter. Some of our commands know how to tilde-expand the
option value even when given in the stuck form, but not all of
them do.
* When you give a revision parameter to a command, make sure the parameter is
not ambiguous with a name of a file in the work tree. E.g. do not write
`git log -1 HEAD` but write `git log -1 HEAD --`; the former will not work
if you happen to have a file called `HEAD` in the work tree.
* Many commands allow a long option `--option` to be abbreviated
only to their unique prefix (e.g. if there is no other option
whose name begins with `opt`, you may be able to spell `--opt` to
invoke the `--option` flag), but you should fully spell them out
when writing your scripts; later versions of Git may introduce a
new option whose name shares the same prefix, e.g. `--optimize`,
to make a short prefix that used to be unique no longer unique.
ENHANCED OPTION PARSER
----------------------
From the Git 1.5.4 series and further, many Git commands (not all of them at the
time of the writing though) come with an enhanced option parser.
Here is a list of the facilities provided by this option parser.
Magic Options
~~~~~~~~~~~~~
Commands which have the enhanced option parser activated all understand a
couple of magic command-line options:
-h::
gives a pretty printed usage of the command.
+
---------------------------------------------
$ git describe -h
usage: git describe [<options>] <commit-ish>*
or: git describe [<options>] --dirty
--contains find the tag that comes after the commit
--debug debug search strategy on stderr
--all use any ref
--tags use any tag, even unannotated
--long always use long format
--abbrev[=<n>] 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,