Buttle Butkus
Buttle Butkus

Reputation: 9466

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

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.

Upvotes: 6

Views: 5002

Answers (2)

almondandapricot
almondandapricot

Reputation: 331

git config --list --show-scope gives the scope of the config setting - exactly what you want and a bit more convenient. This seems to have been introduced between versions 2.23 and 2.27 (in git for Windows)

Upvotes: 3

10101
10101

Reputation: 329

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

Upvotes: 6

Related Questions