Git - Config

> Code - (Programming|Computer) Language > Code Versioning > Git

1 - About

The git config command.

Advertising

3 - Syntax

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

3.1 - Resource Location (Section, Key, Value)

The name is actually:

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

The value will be escaped.

Example:

git config core.editor emacs

where:

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

3.2 - Type

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

4 - 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
Advertising

5 - Management

5.1 - Add

git config --global core.editor emacs

For my laptop:

git config --global core.editor ed.bat

5.2 - List

List the configuration

git config --list
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true
user.name=Nicolas Gerard
[email protected]
credential.helper=wincred
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly

5.3 - Get

  • with bash
git config --list | grep myConfigKey

6 - Documentation / Reference

code/version/git/config.txt · Last modified: 2018/09/26 10:13 by gerardnico