我想显示所有配置的Git部分。

我只找到了git-config-getcore.editor,我希望输出全局配置的所有内容,而不仅仅是配置的默认编辑器。


当前回答

最短的,

git config -l

显示所有从系统、全局和本地继承的值

其他回答

从Git 2.26.0开始,您可以使用--show scope选项:

git config --list --show-scope

示例输出:

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

它可以与

--本地用于项目配置,--全局用于用户配置,--系统用于所有用户的配置--显示原点以显示配置文件的确切位置

您可以使用:

git config --list

或者查看~/.gitconfig文件。本地配置将位于存储库的.git/config文件中。

Use:

git config --list --show-origin

查看该设置的定义位置(全局、用户、回购等)

git config --list

只有一条路要走。我通常只打开.gitconfig。

您还可以调用git-config-e直接在编辑器中打开配置文件。Git配置文件比-l输出更可读,所以我总是倾向于使用-e标志。

综上所述:

git config -l  # List Git configuration settings (same as --list)
git config -e  # Opens Git configuration in the default editor (same as --edit)

如果没有参数,它将与local.git/config交互。使用--global,它与~/.gitconfig交互。通过--system,它与$(前缀)/etc/gitconfig交互。

(我真的找不到$(前缀)的意思,但它似乎默认为$HOME。)

如果您只想列出Git配置的一部分,例如别名、核心、远程等,那么只需通过grep发送结果即可。类似于:

git config --global -l | grep core