Search notes:

Git Options

The behavior of git commands can be influenced and controlled using so-called options.
Each option has a name which can be given a name
When running a command, the option can be specified with the -c parameter between git and the command name. In the following command, the option with the name user.name is given the value Hausi Peter while the command git commit is executed:
git -c user.name='Hausi Peter' commit . -m "…"

Storing options

The value of options can be stored so that commands can be entered without having to use the -c command line argument.

Scope of stored options

There are three scopes where options can be stored:
  • system wide,
  • per user (referred to as globally stored) and/or
  • per repository (referred to as locally stored).
If a value for an option is stored in multiple locations, the local value takes precedence. If no local option is available, the global one takes precedence. Options that are assigned a value with -c take precedence over all other locations.

Setting options

Options are set with git config.
git config does not check if the option name or value is valid. It is just a dumb frontend for storing or retrieving values.
The following command assigns the value false to the option named core.autocrlf in the current repository (locally stored).
Note that there is no equal sign to assign the value:
git config core.autocrlf false
This command assigns a value for the current user (globally stored):
git config --global user.name "René Nyffenegger"
Store an option for the entire system:
git config --system core.longpaths true

Option names

An option name contains at least one dot. The part before the first dot is the name of section to which the option belongs.
Trying to store a value without a dot results in an error:
$ git config  abc  val-one
error: key does not contain a section: abc
The following command stores the value val-two for the name nam in the section sec:
$ git config  sec.nam  val-two
$ cat .git/config
[core]
  …
[sec]
        nam = val-two
Using a name with two dots:
$ git config  sss.ttt.uuu  val-two
$ cat .git/config
[sec]
        nam = val-two
[sss "ttt"]
        uuu = val-two

List of all possible options

A list of options that are processed by one or more git commands can be obtained with
git help -c

Interesting options

Some interesting, IMHO, Git options include:
branch.*
core.abbrev
core.autocrlf Should be set to false because it applies to all files, even binary ones and is local, not versionized in a repository. The eol directive in .gitattributes is therefore the preferred alternative.
core.safecrlf
core.editor Names the editor with which commit and tag messages are composed. If not set, git will use value of environment variables EDITOR or VISUAL, if these variable are not set to vi.
core.filemode If true, git will honor the executable bit of files (some filesystem don't have such a bit).
core.hooksPath Set the (relative or absolute) location (directory) for Git hooks. Without this setting, git looks for hooks below .git/hooks.
core.ignorecase
core.logallrefupdates Enables the reflog. Value can be set to true and always
core.repositoryformatversion Every repository specifies a (local) value for core.repositoryformatversion which specifies what operations are allowed in a repository.
core.symlinks If true (which is the default unless git clone or git init determines it should be false), symbolic link files will be checked as symlinks, otherwise as ordinary files containing the text. Setting this value to false is useful on filesystems like FAT.
core.whitespace Specifies how and if whitespace problems should be notified
credential.helper ? Contains a path such as credential.helper=!"C:/Users/rene/bin/git/mingw64/libexec/git-core/git-credential-manager-core.exe", a value such as manager-core or … ?
credential.helperselector.selected The value of credential.helperselector.selected might be manager-core
diff.tool Specify the default tool with which differences between commits are shown when using git difftool
difftool.prompt true or (possibly better?) false. If --false, the command line option --no-prompt will be used when invoking git difftool.
format.pretty The default pretty format for the git log, git show and git whatchanged commands.
gc.reflogExpire Controls when reachable reflogs expire and get purged. Default is 90 days.
gc.reflogExpireUnreachable Controls when unreachable reflogs expire and get purged. Default is 30 days.
http.proxySSLCAInfo Name of the file (for example C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt) that contains the certificate with which a peer is verified in git pull or git push over HTTPS.
init.templateDir Location of the template directory used by the git init command. init.templateDir has lower precedence than the environment variable $GIT_TEMPLATE_DIR.
merge.renamelimit
pull.rebase
pull.ff
push.default Defines the action git push should take if no refspec is explicitly given. The value can be set to one of nothing, current, upstream, simple and matching. The default in Git 2 is simple.
remote.origin.url Compare with git remote get-url origin
safe.directory
user.email Used for committer information (git commit).
user.name Used for committer information (git commit). Compare with credential.username.
web.browser Used, for example(?) by git web--browse. One of the options that are very like set with the --global option of git config. See also browser related options

See also

git config changes option values in config files.
Commands have the common option -c option=value which allows to override an option value when executing a git command.
Options in the credential and help section.
~/.gitconfig
man git-config describes has a «non-comprehensive and not necessarily complete» list of git options (which are referred to as «variables» in said man page).

Index