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

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


当前回答

如何编辑全局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

其他回答

在基于Linux的系统上,您可以通过以下方式查看/编辑配置文件

vi/vim/nano .git/config

确保您在Gitinit文件夹中。

如果您想使用--global-config

vi/vim/nano .gitconfig

在/home/userName上

这将有助于编辑:https://help.github.com/categories/setup/

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 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

它可以与

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

在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

如何编辑全局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