我想显示所有配置的Git部分。
我只找到了git-config-getcore.editor,我希望输出全局配置的所有内容,而不仅仅是配置的默认编辑器。
我想显示所有配置的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
其他回答
在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 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
如何编辑全局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-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