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

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


当前回答

在Windows中,要编辑全局配置,请从gitbash运行(但不从常规命令提示符运行)

notepad ~/.gitconfig

文件的位置列在https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Where-system-global-and-local-Windows-Git-config-files-are-saved

其他回答

Git2.6(2015年9月/10月)将添加选项--name以简化Git-config-l的输出:

参见Jeff King(peff)的提交a92330d、提交f225987、提交9f1429d(2015年8月20日)。见SZEDER Gábor(SZEDER)提交的提交ebca2d4(2015年8月20日)和提交905f203、提交578625f(2015年7月10日)。(于2015年8月31日由Junio C Hamano--gitster--在commit fc9dfda中合并)

config:添加“--name only”选项以仅列出变量名称“git-config”只能显示值或名称值对,因此如果shell脚本需要设置配置变量的名称,它必须运行“git-config-list”或“--getregexp”并解析输出以将配置变量名称与其值分开。然而,这种解析无法处理多行值。虽然“git-config”可以为换行安全解析生成以null结尾的输出,但在这种情况下没有用,因为shell无法处理null字符。甚至我们自己的bash完成脚本也存在这些问题。通过介绍来帮助完成脚本和shell脚本“--name only”选项用于修改“--list”的输出,以及“--getregexp”只列出配置变量的名称,因此它们不会必须执行容易出错的后处理以分离变量名从他们的价值观。

git config --list

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

如何编辑全局Git配置?

简短回答:git-config--edit--global


要了解Git配置,您应该知道:

Git配置变量可以存储在三个不同的级别。每个级别将覆盖上一级别的值。

1.系统级(应用于系统上的每个用户及其所有存储库)

要查看,git-config--list--system(可能需要sudo)要设置,git-config--system color.ui true要编辑系统配置文件,请使用git-config-edit--system

2.全局级别(用户个人特定的值)。

要查看,git-config--list--global要设置,git-config--全局user.name xyz要编辑全局配置文件,请使用git-config--edit--global

3.存储库级别(特定于单个存储库)

要查看,git-config--list--local要设置,git-config--local-core.ignorecase true(--local可选)要编辑存储库配置文件,请使用git-config--edit--local(--local可选)

如何查看所有设置?

运行git-config--list,显示系统、全局和(如果在存储库中)本地配置运行git-config--list--show origin,同时显示每个配置项的源文件

如何读取特定配置?

例如,运行git-config user.name获取user.name。您还可以指定选项--system、--global、--local以在特定级别读取该值。


参考:1.6入门-首次安装Git

要查找所有配置,只需编写以下命令:

git config --list

在本地,我运行此命令。

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
user.email=infomasud@gmail.com
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

您也可以使用cat~/.gitconfig。