如何在 Windows 上打印 git 配置设置 (core.autocrlf) 的值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1475199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I print out the value of a git configuration setting (core.autocrlf) on Windows?
提问by S. Michaels
I'm trying to fix a problem with CRLF on Windows.
我正在尝试解决 Windows 上的 CRLF 问题。
How do I see what the value of the configuration setting core.autocrlf
is set to on my system?
如何查看core.autocrlf
系统上的配置设置值?
回答by Chris Missal
If you're using Git Bash:
如果您使用的是 Git Bash:
git config --get core.autocrlf
And for the global config:
对于全局配置:
git config --global --get core.autocrlf
回答by Relic
Where ever your git repo is ie:public_html do:
你的 git repo 在哪里 ie:public_html 做:
[~/public_html]$ git config -l
this should list your whole config for that repo. You could also always use:
这应该列出该回购的整个配置。您也可以始终使用:
[~/public_html]$ git config -help
this will show you all the list commands
这将显示所有列表命令
回答by user151516
In the .git dir there is a file named 'config' which has your settings in. This help?
在 .git 目录中有一个名为“config”的文件,其中包含您的设置。这有帮助吗?
回答by Enze Chi
I am not sure if you set that option as global, that can override the local configuration. You can have a try. If it is yes, you don't need care too much about the one inside the git repo.
我不确定您是否将该选项设置为全局,这可以覆盖本地配置。你可以试试。如果是的话,你不需要太在意 git repo 里面的那个。
回答by eloibm
If you want to check your settings, you can use the git config --list
command to list all the settings Git can find at that point:
如果你想检查你的设置,你可以使用该git config --list
命令列出 Git 可以找到的所有设置:
$ git config --list
user.name=John Doe
[email protected]
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
...
You may see keys more than once, because Git reads the same key from different files (/etc/gitconfig
and ~/.gitconfig
, for example). In this case, Git uses the last value for each unique key it sees.
您可能会看到键不止一次,因为混帐读取不同的文件相同的密钥(/etc/gitconfig
和~/.gitconfig
,例如)。在这种情况下,Git 使用它看到的每个唯一键的最后一个值。
You can also check what Git thinks a specific key's value is by typing git config <key>
:
您还可以通过键入git config <key>
以下内容来检查 Git 认为特定键的值是什么:
$ git config user.name
John Doe
Here the used documentation
这里使用的文档
回答by Number945
To read from particular value from a git configuration files ,
要从 git 配置文件中读取特定值,
git config --system –get core.autocrlf
git config --system –get core.autocrlf
Reads the value core.autocrlf
from configuration file of Git set at System level.
core.autocrlf
从系统级别设置的 Git 配置文件中读取值。
There are 3 levels of configuration files for git :
git 有 3 个级别的配置文件:
1) Local (use --local)
1)本地(使用--local)
2) System (use --system)
2)系统(使用--system)
3) Global (use --global)
3)全局(使用--global)
Q) What will happen if I skip to mention the level of a file ?
Q) 如果我跳过提到文件的级别会发生什么?
In case of Read operation, then value will be searched in all the 3 configuration files.
在读取操作的情况下,将在所有 3 个配置文件中搜索值。
git config –get core.autocrlf
git config –get core.autocrlf
Q) What does it mean if it does not print anything ?
Q) 如果它不打印任何东西是什么意思?
It simply means , that no such configuration is set.
这只是意味着,没有设置这样的配置。
Q) What if a configuration value is mentioned in all 3 files ? Which will it show ?
问)如果在所有 3 个文件中都提到了配置值怎么办?它会显示哪个?
Well, highest priority to local , then global and then system. Sometimes a config variable can have multiple value , say in local. In that case the last value mentioned in the local config file, it will show.
好吧,最高优先级是 local ,然后是 global ,然后是 system 。有时一个配置变量可以有多个 value ,比如在本地。在这种情况下,将显示本地配置文件中提到的最后一个值。
Q) What if I want to see all values for a config variable ?
问)如果我想查看配置变量的所有值怎么办?
Use --get-all
like
使用--get-all
喜欢
git config --local --get-all core.autocrlf
git config --local --get-all core.autocrlf
Q) What happens if I write git config --get-all core.autocrlf
?
问)如果我写了会git config --get-all core.autocrlf
怎样?
Clearly you have skipped to write the level of file , hence in that case it shows for all files and all values mentioned in them for this config variable.
很明显,您跳过了写入文件级别,因此在这种情况下,它会显示所有文件和其中提到的所有值,用于此配置变量。