Git config: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 48: Line 48:
===Configure the Commit Author===
===Configure the Commit Author===


This command configures the current repository only:
This command configures the current repository only (<code>--local</code> is implied by default):


git config user.name "Ovidiu Feodorov"
<syntaxhighlight lang='bash'>
git config user.email "ovidiu@feodorov.com"
git config user.name "Ovidiu Feodorov"
git config user.email "ovidiu@feodorov.com"
</syntaxhighlight>


The configuration propagates to [[.git/config#.5Buser.5D|.git/config [user] section]].
The configuration propagates to [[.git/config#.5Buser.5D|.git/config [user] section]].
Line 57: Line 59:
The same effect can be achieved by setting [[Git_Environment_Variables#GIT_AUTHOR_NAME|GIT_AUTHOR_NAME]] and [[Git_Environment_Variables#GIT_AUTHOR_EMAIL|GIT_AUTHOR_EMAIL]] environment variables.
The same effect can be achieved by setting [[Git_Environment_Variables#GIT_AUTHOR_NAME|GIT_AUTHOR_NAME]] and [[Git_Environment_Variables#GIT_AUTHOR_EMAIL|GIT_AUTHOR_EMAIL]] environment variables.


To configure commit author information for all repositories the user interacts with. If set on a specific repository, that setting will take precedence. For more details on configuration hierarchy, see [[Git_Configuration#Overview|Git Configuration]].
To configure commit author information for all repositories the user interacts with, use <code>--global</code>. If set on a specific repository, the repository-specific setting will take precedence. For more details on configuration hierarchy, see [[Git_Configuration#Overview|Git Configuration]].


git config --global user.name "Ovidiu Feodorov"
<syntaxhighlight lang='bash'>
git config --global user.email "ovidiu@feodorov.com"
git config --global user.name "Ovidiu Feodorov"
git config --global user.email "ovidiu@feodorov.com"
</syntaxhighlight>


===Configure an Alias===
===Configure an Alias===

Revision as of 02:55, 13 June 2021

Internal

Overview

git config is used to manipulate entries in Git's configuration files. There are three levels of configuration files, listed below from the highest precedence to the lowest:

1. file (.git/config). This file contains repository-specific configuration and has the highest precedence. Repository-specific configuration is manipulated when git config is gets the "--file" option. This is the default.

2. global (~/.gitconfig). This file contains user-specific configuration and it is manipulated when git config gets the "--global" option.

3. system (/etc/gitconfig). This file contains system-wide configuration and can be manipulated with the "--system" option, if the user has proper permissions.

The configuration files are not replicated during git clone.

More info:

git config --help

Configuration Operations

List the Configuration

git config [--system|--global|--local] -l

Configure a Setting

git config [--system|--global|--file] <some.git.option> <value>

Get a Setting

git config --get <option-name>

Remove a Setting

git config --unset [--file|--global|--system] <some.git.option>

Remote Manipulation

See:

Remotes

Recipes

Configure the Commit Author

This command configures the current repository only (--local is implied by default):

git config user.name "Ovidiu Feodorov"
git config user.email "ovidiu@feodorov.com"

The configuration propagates to .git/config [user] section.

The same effect can be achieved by setting GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables.

To configure commit author information for all repositories the user interacts with, use --global. If set on a specific repository, the repository-specific setting will take precedence. For more details on configuration hierarchy, see Git Configuration.

git config --global user.name "Ovidiu Feodorov"
git config --global user.email "ovidiu@feodorov.com"

Configure an Alias

git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'

Turn Off SSL Server Certificate Verification for a Specific Repository

The setting is controlled by http.sslVerify configuration element:

cd <repository-dir>
git config http.sslVerify true|false

and ends up in modifying .git/config's [http] section as follows:

[http]
       sslVerify = true|false

The configuration setting is overridden by the GIT_SSL_NO_VERIFY environment variable.