Git config: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
=Internal=
=Internal=
* [[Git_Commands#Configuration_Commands|Git Commands]]
* [[Git_Commands#Configuration_Commands|Git Commands]]
* [[Git Configuration]]
* [[Git Configuration]]
Line 6: Line 5:


=Overview=
=Overview=
<code>git config</code> is used to read and manipulate entries in the [[Git_Configuration#Overview|Git configuration files]].
<code>git config</code> is used to read and manipulate entries in the [[Git_Configuration#Overview|Git configuration files]].


Line 15: Line 13:


=Configuration Operations=
=Configuration Operations=
==List the Configuration==
==List the Configuration==
 
<syntaxhighlight lang='bash'>
git config [--system|--global|--local] -l
git config [--system|--global|--local] -l
 
</syntaxhighlight>
===List the Remote Origin URL===
===List the Remote Origin URL===
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
git config --get remote.<origin-name>.url
git config --get remote.<origin-name>.url
Line 28: Line 24:


==Configure a Setting==
==Configure a Setting==
<syntaxhighlight lang='bash'>
git config [--system|--global|--file] <some.git.option> <value>
</syntaxhighlight>


<font size=-1>
<syntaxhighlight lang='bash'>
git config [--system|--global|--file] <''some.git.option''> <''value''>
git config --global push.autoSetupRemote true
</font>
</syntaxhighlight>
 
<font size=-1>
git config --global push.autoSetupRemote true
</font>


==Get a Setting==
==Get a Setting==
 
<syntaxhighlight lang='bash'>
git config --get <''option-name''>
git config --get <some.git.option.name>
 
</syntaxhighlight>
==Remove a Setting==
==Remove a Setting==
 
<syntaxhighlight lang='bash'>
git config --unset [--file|--global|--system] <''some.git.option''>
git config --unset [--file|--global|--system] <some.git.option>
 
</syntaxhighlight>
==Remote Manipulation==
==Remote Manipulation==
See: {{Internal|Git_Concepts#Remote|Remotes}}
See: {{Internal|Git_Concepts#Remote|Remotes}}


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


Line 71: Line 63:
</syntaxhighlight>
</syntaxhighlight>


===Configure an Alias===
==Configure an Alias==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'
git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'
</syntaxhighlight>
</syntaxhighlight>


===<span id='http.sslVerify'></span>Turn Off SSL Server Certificate Verification for a Specific Repository===
==<span id='http.sslVerify'></span>Turn Off SSL Server Certificate Verification for a Specific Repository==


The setting is controlled by http.sslVerify configuration element:
The setting is controlled by http.sslVerify configuration element:
 
<syntaxhighlight lang='bash'>
cd <''repository-dir''>
cd <repository_dir>
git config http.sslVerify true|false
git config http.sslVerify true|false
 
</syntaxhighlight>
and ends up in modifying .git/config's [[.git/config#.5Bhttp.5D|[http]]] section as follows:
and ends up in modifying .git/config's [[.git/config#.5Bhttp.5D|[http]]] section as follows:
 
<syntaxhighlight lang='ini'>
[http]
[http]
        sslVerify = true|false
    sslVerify = true|false
 
</syntaxhighlight>
The configuration setting is overridden by the [[Git_Environment_Variables#GIT_SSL_NO_VERIFY|GIT_SSL_NO_VERIFY]] environment variable.
The configuration setting is overridden by the [[Git_Environment_Variables#GIT_SSL_NO_VERIFY|GIT_SSL_NO_VERIFY]] environment variable.

Revision as of 22:58, 9 January 2024

Internal

Overview

git config is used to read and manipulate entries in the Git configuration files.

More info:

git config --help

Configuration Operations

List the Configuration

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

List the Remote Origin URL

git config --get remote.<origin-name>.url
git config --get remote.origin.url

Configure a Setting

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

Get a Setting

git config --get <some.git.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.