Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show scope for each item in `git config --list`

Tags:

git

git-bash

In windows bash it seems git config --list shows settings for multiple scopes but doesn't tell you which scope each is for.

I am trying to make sure I never have a CRLF problem again by setting core.autocrlf to false for everything.

git config --list gives me something like this:

$ git config --list
core.symlinks=false
core.autocrlf=input         // <-- HERE
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
gui.recentrepo=C:/Users/Buttle/PhpstormProjects/stuffs
gui.recentrepo=C:/Users/Buttle/PhpstormProjects/lolcatz
user.name=buttletime
[email protected]
core.autocrlf=false                // <-- AND HERE
credential.helper=cache --timeout=3600
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://github.com/buttletime/lolcatz.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
gui.wmstate=normal
gui.geometry=1385x655+182+182 420 192
branch.master.remote=origin
branch.master.merge=refs/heads/master

It seems like the 2nd one is probably local to my lolcatz project. But my global setting is also "false" when I check it.

like image 938
Buttle Butkus Avatar asked May 04 '16 01:05

Buttle Butkus


People also ask

What is git configuration scope?

There're 3 scopes of configuration: local ( --local , default) global ( --global ) system ( --system )

How do I know which git config to use?

You can find this config file in the . git directory of whatever repository you're currently using. Anyone can view/edit these configuration settings.


1 Answers

git config --list --show-origin gives the source file of the config setting.

From the FILES section of man git-config:

If not set explicitly with --file, there are four files where git config will search for configuration options:

$(prefix)/etc/gitconfig: System-wide configuration file.

$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. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.

~/.gitconfig: User-specific configuration file. Also called "global" configuration file.

$GIT_DIR/config: Repository specific configuration file.

Edit: Looks like the --show-origin flag was introduced in v2.8

like image 161
10101 Avatar answered Sep 27 '22 22:09

10101