Skip to content
Search

Git:Config

lastmod 2026-01-02created 2014-02-1625 edits

Get and set repository or global options.

SYNOPSIS

git config [<file-option>] [type] [-z|--null] name [value [value_regex]]
git config [<file-option>] [type] --add name value
git config [<file-option>] [type] --replace-all name value [value_regex]
git config [<file-option>] [type] [-z|--null] --get name [value_regex]
git config [<file-option>] [type] [-z|--null] --get-all name [value_regex]
git config [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
git config [<file-option>] --unset name [value_regex]
git config [<file-option>] --unset-all name [value_regex]
git config [<file-option>] --rename-section old_name new_name
git config [<file-option>] --remove-section name
git config [<file-option>] [-z|--null] -l | --list
git config [<file-option>] --get-color name [default]
git config [<file-option>] --get-colorbool name [stdout-is-tty]
git config [<file-option>] -e | --edit

Default gitconfig

The contents of etc/gitconfig included with a fresh Git installation (on Windows) are as follows.

[core]
    symlinks = false
    autocrlf = false
[color]
    diff = auto
    status = auto
    branch = auto
    interactive = true
[pack]
    packSizeLimit = 2g
[help]
    format = html
[http]
    sslCAinfo = /bin/curl-ca-bundle.crt
[sendemail]
    smtpserver = /bin/msmtp.exe

[diff "astextplain"]
    textconv = astextplain
[rebase]
    autosquash = true

Config file location

The config file locations are listed below.

--global
use global config file
--system
use system config file
--local
use repository config file
-f, --file <file>
use given config file

Setting check

Enter the following to view the configured settings.

git config --global -list

Save password

To save credentials, enter the following inside the repository.

git config credential.helper store

Save globally:

git config --global credential.helper store

Setting up name and e-mail address

To set the Git user name and e-mail address:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Applying user information temporarily

git -c user.name=사용자명 -c user.email=이메일주소 ...

Temporarily changes the user name and e-mail address.

Installation Options line endings

Also, for users of Unix/Mac:

git config --global core.autocrlf input
git config --global core.safecrlf true

For Windows users:

git config --global core.autocrlf true
git config --global core.safecrlf true

Console UI Color setting

To color the text printed to the console:

git config --global color.ui auto

Alias setting

To assign a long command to a single alias:

$ git config alias.log20 "log -20 --decorate --oneline --graph --all"

push.default

The push.default property is an option for the default behavior when pushing. Usage:

$ git config --global push.default matching
  • matching: compares all local branch names with the remote and pushes every branch with a matching name.
  • simple: pushes only the branch you are currently working on.

SSL certificate rejected

An SSL certificate problem may produce the following message.

error: SSL certificate problem, verify that the CA cert is OK. Details:

In this case, you can SKIP SSL certificate verification as follows.

$ git config --global http.sslVerify false

Http Post buffer size

The following error may occur.

fatal: The remote end hung up unexpectedly

This is a problem when the postBuffer is smaller than the source file size. Set the HTTP POST request buffer size.

$ git config --global http.postBuffer 524288000

i18n setting

UTF-8 setting (applies to Window environments)

$ git config --global i18n.commitEncoding cp949
$ git config --global i18n.logOutputEncoding cp949

Proxy setting

Either use environment variables such as http_proxy, https_proxy, all_proxy,

or, to specify it separately, add the http.proxy setting:

git config --global http.proxy http://128.0.0.1:8080

In addition, most sites use HTTPS, and certificate verification may fail when going through a proxy.

Add the http.sslVerify=false setting to bypass certificate verification:

git config --global http.sslVerify false

Internal Git repositories are usually located inside the proxy network, so you set up a proxy exception for them.

Git lets you apply settings to a specific URL using http.<url>.*.

For example, if https://code.oofbird.me is the Git repository, set the proxy to empty as follows.

git config --global http.https://code.oofbird.me.proxy ""

To save it directly in the .gitconfig file:

[http]
    proxy = http://128.0.0.1:8080
    sslVerify = false
[http "https://code.oofbird.me"]
    proxy =

Remove credentials

Retype:

$ git config credential.helper store
git config --list --show-origin

Include another gitconfig file

Git (1.7.10+) now supports this syntax in .gitconfig:

[include]
    path = /path/to/file

See also

Favorite site

References


  1. Set_up_a_convenient_git_alias_-_John_Grib.pdf ↩

  2. Windows_-remove_credentials_from_git-_Stack_Overflow.pdf ↩

  3. en: Git - git-credential-store Documentation ↩

author Zer0 sitemap