How can I print out the value of a git configuration setting (core.autocrlf) on Windows?

GitNewline

Git Problem Overview


I'm trying to fix a problem with CRLF on Windows.

How do I see what the value of the configuration setting core.autocrlf is set to on my system?

Git Solutions


Solution 1 - Git

If you're using Git Bash:

git config --get core.autocrlf

And for the global config:

git config --global --get core.autocrlf

Solution 2 - Git

Where ever your git repo is ie:public_html do:

[~/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

Solution 3 - Git

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
user.name=John Doe
user.email[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.

You can also check what Git thinks a specific key’s value is by typing git config <key>:

$ git config user.name
John Doe

Here the used documentation

Solution 4 - Git

In the .git dir there is a file named 'config' which has your settings in. This help?

Solution 5 - Git

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.

Solution 6 - Git

To read from particular value from a git configuration files ,

git config --system –get core.autocrlf

Reads the value core.autocrlf from configuration file of Git set at System level.

There are 3 levels of configuration files for git :

  1. Local (use --local)

  2. System (use --system)

  3. Global (use --global)

Q) What will happen if I skip to mention the level of a file ?

In case of Read operation , then value will be searched in all the 3 configuration files.

git config –get core.autocrlf

Q) What does it mean if it does not print anything ?

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 ?

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.

Q) What if I want to see all values for a config variable ?

Use --get-all like

git config --local --get-all core.autocrlf

Q) What happens if I write 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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionS. MichaelsView Question on Stackoverflow
Solution 1 - GitChris MissalView Answer on Stackoverflow
Solution 2 - GitRelicView Answer on Stackoverflow
Solution 3 - GiteloibmView Answer on Stackoverflow
Solution 4 - Gituser151516View Answer on Stackoverflow
Solution 5 - GitEnze ChiView Answer on Stackoverflow
Solution 6 - GitNumber945View Answer on Stackoverflow