Cam*_*ner 1570
您可以使用git config --list或查看您的~/.gitconfig文件.本地配置将位于存储库的.git/config文件中.
lin*_*ize 228
最短的,
git config -l
Run Code Online (Sandbox Code Playgroud)
显示所有继承的值:system,global和local
Roo*_*ook 99
git config --list
Run Code Online (Sandbox Code Playgroud)
是一种方法.我通常只是开放.gitconfig.
sam*_*sam 97
如何编辑我的全局 git配置?
简短回答: git config --edit --global
要了解git配置,您应该知道:
Git配置变量可以存储在3个不同的级别中.每个级别都会覆盖上一级别的值.
1.系统级别(适用于系统上的每个用户及其所有存储库)
git config --list --system(可能需要sudo)git config --system color.ui truegit config --edit --system 2.全球水平(个人特定的价值,用户.)
git config --list --globalgit config --global user.name xyzgit config --edit --global3.存储库级别(特定于该单个存储库)
git config --list --localgit 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在特定级别读取该值.leo*_*eon 29
您也可以直接调用git config -e打开编辑器中的配置文件.git-config文件的-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)
Run Code Online (Sandbox Code Playgroud)
.git/config.--global与之交互~/.gitconfig.--system互动$(prefix)/etc/gitconfig.(无法真正找到什么$(prefix)意思,但它似乎默认为$HOME.)
小智 13
要轻松显示您的全局 Git 配置,请使用:
git config --global --list显示所有配置的列表。git config --global --get user.name显示您的用户名。git config --global --get user.email显示您的电子邮件。git config --global credential.helper验证凭据。git config --global gui.recentrepo找到你最近的仓库。您可能需要指定要在哪里读取这些配置,只需添加 level 选项:
--system:系统级别,适用于系统上的每个用户及其所有存储库。--global:全局级别,其值针对您(用户)个人而言。--local:存储库级别特定于该单个存储库。Git 2.6(2015年9月/ 10月)将添加选项--name-only以简化输出git config -l:
请参阅Jeff King()提交a92330d,提交f225987,提交9f1429d(2015年8月20日).
请参阅提交ebca2d4(2015年8月20日),并提交905f203,提交578625f(2015年8月10日)作者:SZEDERGábor().(由Junio C Hamano合并- -在commit fc9dfda,2015年8月31日)peffszeder
gitster
config:添加'--name-only'选项仅列出变量名称'
git config'只能显示值或名称 - 值对,因此如果shell脚本需要set配置变量的名称,则必须运行'git config --list'或'--get-regexp'并将输出解析为其值中的独立配置变量名称.
但是,这样的解析不能处理多行值.虽然'
git config'可以为换行安全解析生成以空值终止的输出,但在这种情况下没有用,因为shell无法处理空字符.甚至我们自己的bash完成脚本也会遇到这些问题.
一般来说,帮助完成脚本和shell脚本,通过引入'
--name-only'选项来修改输出'--list'和'--get-regexp'仅列出配置变量的名称,这样他们就不必执行容易出错的后处理将变量名称与其值分开.
如果您只想列出 Git 配置的一部分,例如alias、core、remote等,您可以通过 grep 管道传输结果。就像是:
git config --global -l | grep core
Run Code Online (Sandbox Code Playgroud)
一件重要的事git config:
git config有--local,--global而且--system水平和相应的文件。
所以,你可以使用git config --local,git config --global和git config --system。
默认情况下,如果未传递任何配置选项,git config将写入本地级别。本地配置值存储在一个文件中,该文件可以在存储库的.git目录中找到:.git/config
全局级别配置是特定于用户的,这意味着它将应用于操作系统用户。全局配置值存储在用户主目录中的文件中。~/.gitconfig在Unix系统和C:\Users\<username>\.gitconfigWindows上。
系统级配置应用于整个计算机。这涵盖了操作系统和所有存储库上的所有用户。系统级配置文件位于gitconfig系统根路径之外的文件中。$(prefix)/ etc / gitconfig在Linux系统上。在Windows上,可以在中找到该文件C:\ProgramData\Git\config。
因此,您的选择是找到该全局.gitconfig文件并进行编辑。
或者您可以使用git config --global --list。
这正是您需要的线。
要查找所有配置,只需编写以下命令:
git config --list
Run Code Online (Sandbox Code Playgroud)
在我的本地我运行这个命令。
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
Run Code Online (Sandbox Code Playgroud)
从 Git 2.26.0 开始,您可以使用--show-scope选项:
git config --list --show-scope
Run Code Online (Sandbox Code Playgroud)
示例输出:
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
Run Code Online (Sandbox Code Playgroud)
它可以与
--local对于项目配置, --global对于用户配置, --system对于所有用户的配置--show-origin 显示确切的配置文件位置