2. Configuration¶
2.1. Customising Git¶
Git is a very powerful and complex tool. Thus, it allows you to customise it according to your personal needs. Customisations can be made for several settings, such as:
Personal user details
Aliases
Preferred editor
Push strategy
Hooks
2.2. Configuration Utility¶
The git
command line utility provides an interface to configure itself:
git config
usage: git config [<options>]
By default, git config
is looking up configuration options in the following order:
Description |
Configuration File |
|
---|---|---|
Local repository specific configuration |
|
|
Global user specific configuration |
|
|
System-wide configuration file |
|
|
Hint
These configuration files are plain-text. You can also set the configuration options in the file directly instead via CLI.
See also
If you want to get deeper details into the config utility, have a look at man git-config
, git config --help
or the Customizing Git - Git Configuration chapter of the official docs.
2.3. List Config Options¶
To display the configuration options you can run the list command:
git config -l [location-flag]
git config --list [location-flag]
Hint
If you want to show the origin of the setting, add the --show-origin
flag to the list command above.
2.4. Set Config Options¶
To set a configuration option, use the following command:
git config [location-flag] name value
2.5. User & Email¶
In your Git lifetime you’ll come along to several Git config options. However, the probably most common ones are:
user.name
: Your name (most likely your real name)user.email
: Your e-mail address
Important
These configuration options are quite important, because they will be used in every commit of yours. This is becoming even more important later on, when you’re working with Git collaboration platforms.
2.6. Editor¶
When working with Git, there are several occasions when an editor is opened. For example when providing a commit message or adding hunks.
Git uses the configured default editor of the OS. If you want to overwrite that, use the following setting:
core.editor
: Name of the editor executable
2.7. Aliases¶
The git
command also supports aliases. Git aliases are basically the same as bash
aliases, except for the following facts:
You still use
git …
as bash commandGit supports you in case of misspellings
Hint
Git aliases might be helpful to people who’re migrating from Subversion to Git, as they often miss svn st
and alike.