How do I show my global Git configuration?
Asked Answered
S

15

1675

I'd like to show all configured Git sections.

I only found git config --get core.editor, and I'd like to output everything that's configured globally, not only the configured default editor.

Susurrate answered 3/9, 2012 at 21:14 Comment(4)
What's wrong with looking at .gitconfig?Stpeter
Note that you will soon (Q3/Q4 2015) have with git 2.6 the option --name-only, to list only the config keys, without their values. See my answer belowPerseid
$ git config --list Checking-Your-SettingsImpediment
It should be git config --global --list as explained deeper in hereLactose
J
2571

You can use:

git config --list

or look at your ~/.gitconfig file. The local configuration will be in your repository's .git/config file.

Use:

git config --list --show-origin

to see where that setting is defined (global, user, repo, etc...)

Jason answered 3/9, 2012 at 21:16 Comment(9)
Thanks, I upvoted you both. I wanted to know the git config --list command because I can look at the effective config in a repository and I can differ local, global and system config with the appropriate parameter (--global, --local, --system). I'll accept your answer as soon as I'm able to because you were a few seconds faster :)Susurrate
Be careful, there are a lot of potential sources for git configuration. Looking at the file gives only a part. @linquize's answer is in fact correct.Ropy
@vonbrand: --list is equivalent to -l.Jason
Shorthands (like -l) come in handy when you become a power user and use the feature often enough, to actually profit from typing less characters. I find it easier to find and remember the long --list option. For less obvious shorthands I often have to check what do they stand for, so I prefer long names. They're even easier, with command completion, when you don't really have to type all characters, but still see whole option name.Pilarpilaster
What if git config --list prints nothing?Alluvion
@MatejJ then maybe your ~ /.gitconfig and .git/config do not have anything in themTeresitateressa
With Git 2.34.1 on Windows, git config --list starts a vi-like editor within the command prompt for an unknown file that contains a load of settings, even though I've set Notepad++ as the editor. Doesn't seem like that should happen. Any ideas? Is this a bug?Aphra
Note that If you have the same setting entry with multiple values listed, the last value (at the botttom) will be in use. The local setting will always override global settings.Catalyze
What is .gitconfig only has a link to a credential helper? [credential] helper = /mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager-core.exeSunless
G
295

The shortest,

git config -l

shows all inherited values from: system, global and local

Guayaquil answered 4/9, 2012 at 4:10 Comment(4)
Does this differ from git config --list, or is it just a shorter way to write it?Undine
@Undine it's just a shorter way to write itMidwinter
The config files may not always show all inherited configurations, but git config -l will show everything. Saved me because git for windows sets autocrlf on the installation, and it's not in any config file I can find.Rego
yes, there is also C:\ProgramData\Git\config file - I guess this is global or system git config filePiccolo
C
253

How do I edit my global Git configuration?

Short answer: git config --edit --global


To understand Git configuration, you should know that:

Git configuration variables can be stored at three different levels. Each level overrides values at the previous level.

1. System level (applied to every user on the system and all their repositories)

  • to view, git config --list --system (may need sudo)
  • to set, git config --system color.ui true
  • to edit system config file, git config --edit --system

2. Global level (values specific personally to you, the user).

  • to view, git config --list --global
  • to set, git config --global user.name xyz
  • to edit global config file, git config --edit --global

3. Repository level (specific to that single repository)

  • to view, git config --list --local
  • to set, git config --local core.ignorecase true (--local optional)
  • to edit repository config file, git config --edit --local (--local optional)

How do I view all settings?

  • Run git config --list, showing system, global, and (if inside a repository) local configs
  • Run git config --list --show-origin, also shows the origin file of each config item

How do I read one particular configuration?

  • Run git config user.name to get user.name, for example.
  • You may also specify options --system, --global, --local to read that value at a particular level.

Reference: 1.6 Getting Started - First-Time Git Setup

Celia answered 28/10, 2017 at 3:44 Comment(5)
git config --list show all global, system and local? i need affirmation :)Sachikosachs
just to add where the config files are: System: C:\ProgramData\Git\config (in windows). Global: C:\Users\user\.gitconfig (Windows) ~/.gitconfig (Linux) Local: project-repo/.git/configPiccolo
@AdiPrasetyo Yes. You can run git config --list --show-origin to find out the origin of each config item.Celia
Every time I try the git config --global --edit command I end up in some crazy editor and after a while arguing with it I want to join some militant group to track down whom made it. So I am sorry, -1 from me.Writeup
There can be more than user specific global config file. per the docs: $XDG_CONFIG_HOME/git/config Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. If you have this file and a ~/.gitconfig you can see that they are both treated as global files using: git config --list --show-origin --show-scopePenner
S
116
git config --list

is one way to go. I usually just open up .gitconfig though.

Stpeter answered 3/9, 2012 at 21:16 Comment(3)
Did you intend ~/.gitconfig or one of the other files mentioned in the FILES section of git help config?Floweret
@Floweret - Sorry, I dont undersrtand. Did I "intend"?Stpeter
I think you meant to say "I usually just open up ~/.gitconfig though.", as git doesn't look for .gitconfig in the current directory, regardless of where you are. (.gitconfig and ~/.gitconfig name different files [usually].) The other files mentioned in git help config have different file names, hence the assumption.Floweret
S
42

Since Git 2.26.0, you can use --show-scope option:

git config --list --show-scope

Example output:

system  rebase.autosquash=true
system  credential.helper=helper-selector
global  core.editor='code.cmd' --wait -n
global  merge.tool=kdiff3
local   core.symlinks=false
local   core.ignorecase=true

It can be combined with

  • --local for project config, --global for user config, --system for all users' config
  • --show-origin to show the exact config file location
Soundproof answered 15/5, 2020 at 10:10 Comment(0)
C
39

You can also call git config -e to open the configuration file in your editor directly. The Git configuration file is much more readable that the -l output, so I always tend to use the -e flag.

So to summarise:

git config -l  # List Git configuration settings (same as --list)
git config -e  # Opens Git configuration in the default editor (same as --edit)
  • Without parameters it interacts with the local .git/config.
  • With --global it interacts with ~/.gitconfig.
  • And with --system it interacts with $(prefix)/etc/gitconfig.

(I couldn't really find what $(prefix) means, but it seems to default to $HOME.)

Covenantor answered 11/4, 2016 at 14:41 Comment(0)
L
23

One important thing about git config:

git config has --local, --global and --system levels and corresponding files.

So you may use git config --local, git config --global and git config --system.

By default, git config will write to a local level if no configuration option is passed. Local configuration values are stored in a file that can be found in the repository's .git directory: .git/config

Global level configuration is user-specific, meaning it is applied to an operating system user. Global configuration values are stored in a file that is located in a user's home directory. ~/.gitconfig on Unix systems and C:\Users\<username>\.gitconfig on Windows.

System-level configuration is applied across an entire machine. This covers all users on an operating system and all repositories. The system level configuration file lives in a gitconfig file off the system root path. $(prefix)/etc/gitconfig on Linux systems. On Windows this file can be found in C:\ProgramData\Git\config.

So your option is to find that global .gitconfig file and edit it.

Or you can use git config --global --list.

This is exactly the line what you need.

Enter image description here

Lactose answered 8/6, 2019 at 12:3 Comment(2)
Is there a way to get the path to any of those files? I know you've explained where they can be found, but my question is from a different approach.Becki
Search for something like "Where to find system, global and local Git config files" and you will get what you need. ;)Lactose
M
19

You can also use cat ~/.gitconfig.

Marder answered 16/7, 2015 at 14:15 Comment(0)
I
16

To list your global Git config:

git config --list --global

To list your local git config:

git config --list --local

Incrust answered 12/11, 2022 at 13:28 Comment(0)
P
15

To easily show your global Git configuration Use:

  • git config --global --list to display list of all configurations.
  • git config --global --get user.name shows your username.
  • git config --global --get user.email displays your email.
  • git config --global credential.helper verify credentials.
  • git config --global gui.recentrepo find your recent repo.

You may need to specify where you want to read those configurations, Just add the level option:

  1. --system: System level which applied to every user on the system and all their repositories.
  2. --global: Global level whose values are specific personally to you, the user.
  3. --local: Repository level has a specific to that single repository.
Princessprinceton answered 22/6, 2023 at 20:6 Comment(1)
I always wondered why '--global' is not '--user' instead.Drinkwater
P
11

Git 2.6 (Sept/Oct 2015) will add the option --name-only to simplify the output of a git config -l:

See commit a92330d, commit f225987, commit 9f1429d (20 Aug 2015) by Jeff King (peff).
See commit ebca2d4 (20 Aug 2015), and commit 905f203, commit 578625f (10 Aug 2015) by SZEDER Gábor (szeder).
(Merged by Junio C Hamano -- gitster -- in commit fc9dfda, 31 Aug 2015)

config: add '--name-only' option to list only variable names

'git config' can only show values or name-value pairs, so if a shell script needs the names of set config variables it has to run 'git config --list' or '--get-regexp' and parse the output to separate config variable names from their values.
However, such a parsing can't cope with multi-line values.

Though 'git config' can produce null-terminated output for newline-safe parsing, that's of no use in such a case, because shells can't cope with null characters.

Even our own bash completion script suffers from these issues.

Help the completion script, and shell scripts in general, by introducing the '--name-only' option to modify the output of '--list' and '--get-regexp' to list only the names of config variables, so they don't have to perform error-prone post processing to separate variable names from their values anymore.

Perseid answered 1/9, 2015 at 6:46 Comment(0)
S
8

If you just want to list one part of the Git configuration, such as alias, core, remote, etc., you could just pipe the result through grep. Something like:

git config --global -l | grep core
Subdue answered 21/7, 2016 at 16:38 Comment(0)
C
5

To find all configurations, you just write this command:

git config --list

In my local i run this command .

Md Masud@DESKTOP-3HTSDV8 MINGW64 ~
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
[email protected]
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
Crumple answered 17/5, 2019 at 18:5 Comment(2)
The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to .gitconfig text files. Read More here : atlassian.com/git/tutorials/setting-up-a-repository/git-configCrumple
Great, can you add that to your answer?Mashie
I
4

On Linux-based systems you can view/edit a configuration file by

vi/vim/nano .git/config

Make sure you are inside the Git init folder.

If you want to work with --global config, it's

vi/vim/nano .gitconfig

on /home/userName

This should help with editing: https://help.github.com/categories/setup/

Itemize answered 24/3, 2016 at 7:15 Comment(0)
K
2

In Windows to edit global config run From git bash (but not from general command prompt)

notepad ~/.gitconfig

Location of files are listed in https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Where-system-global-and-local-Windows-Git-config-files-are-saved enter image description here

Kliment answered 3/9, 2022 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.