Git - Config


The git docs/git-config.html command.


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] [--name-only] --get-regexp name_regex [value_regex]
git config [<file-option>] [type] [-z|--null] --get-urlmatch name URL
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] [--name-only] -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

Resource Location (Section, Key, Value)

The name is actually:

  • the section
  • and the key
  • separated by a dot.

The value will be escaped.


git config core.editor emacs


  • core.editor is the name whereas:
    • core is the section
    • editor is the key
  • emacs is the value


The type specifier can be either:

  • –int
  • –bool,
  • or –path, which does some path expansion

Data Type Checks or transformations are performed on the value.

  • simple decimal number for int
  • a “true” or “false” string for bool
  • path expansion

Configuration files

The parameters are written to the files that depends of the scope parameter.

Scope Command Option File Details
local (Default) –local .git/config
file –file <filename> <filename>
global –global ~/.gitconfig The tilde ~ means the HOME path
system –system $(prefix)/etc/gitconfig

Configuration Subject



By default, it will add to the repository.

git config --global core.editor emacs

For example: How to configure Git to use NotePad++ as editor on Windows?


List the configuration

git config --list
filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true Gerard
[email protected]


  • with bash
myConfigValue=$(git config myConfigKey)
# example
allownonascii=$(git config hooks.allownonascii)
  • with cat to see all branches at once
cat .git/config
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url =
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

Documentation / Reference

Discover More
Git Open Ssh
Git - Client Installation

Git for windows provides a bash and a gui. It provides also all GNU core utility For windows, select the Windows Native OpenSsh if you want to have the ssh-agent with...
Git - Credential

Git makes use of a credential helper (an external utility) to be able to retrieve the credentials) The id of a credential (user, ww) is a URL (Credential context) It will lookup a credential with the...
Git - Git (executable|command line)

The git executable where: --git-dir is the location of the repository files --work-tree is the location of the work tree Command Description add Add file contents to the index add--interactive...
Git - Remote (Tracked Repository)

A remote in Git is a remote repository (ie a remote git server). Git remote manage the set of repositories (“remotes”) whose branches you track. They are also called tracked repositories in reference...
Git - Submodule (modules)

Submodules allow you to keep a Git repository as a subdirectory of another Git repository. package manager A submodule is materialzied as: a subdirectory in your working directory. with its metadata...
Git - Upstream Branch (Tracking branch)

An upstream is a configuration of a local branch that set the remote branch that it's tracking. cloning @{u} or @{upstream} means the upstream branch of the current branch @{upstream} or @{u}...
Git - difftool

This article is the difftool configuration. Is there a diff with the mergetool? meld on linux WinMerge or p4merge on windows git difftool --tool= may be set to one of the following:...
Windows Envrionment Variable Path Shell Script
How to configure Git to use NotePad++ as editor on Windows?

This article shows you how you can configure git to use Notepad++ as editor on your laptop.
How to install and store credentials on Linux with Git Credential Manager and pass?

This article shows you how you can store git credential (username and password) on Linux with: the Git Credential Manager and the gpg/pass...
What are Git Hooks?

hooks is an extension system of Git to execute executable file implemented by external party (ie not Git) that run at specified steps of a command. There are two groups: Client-Side Hooks: Scripts...

Share this page:
Follow us:
Task Runner