Home > Blockchain >  What does "fatal: bad numeric config value 'ward' for 'core.safecrlf': inva
What does "fatal: bad numeric config value 'ward' for 'core.safecrlf': inva

Time:04-08

When I type "git init" (or "git help tutorial") in terminal (MacOS), I get this message: "fatal: bad numeric config value 'ward' for 'core.safecrlf': invalid unit". But when I use commands like "git config --list" or "git config user.name", it works properly. Why do some commands work and others don't? Please, help me to find the problem. Surfing the Internet is not helpful... Many thanks in advance!

CodePudding user response:

core.safecrlf must be boolean (true, false or empty) or warn. To fix your config:

git config --global core.safecrlf warn

CodePudding user response:

phd's answer has the fix you need: fix the spelling of warn (you have it as a typo, ward). The other part of your question, though, does have an answer:

Why do some commands work and others don't?

The data in a .git/config or .gitconfig or other configuration file are largely free-form, a kind of modified INI file. That is, you may create your own sections and subsections containing names and values:

[nadin "data"]
    why = some questions

which creates a new item nadin.data.why, whose value is some questions. Git won't care whether this setting exists, nor what this is set to because Git has no nadin section, much less a nadin.data or nadin.data.why (at least not today, and probably not in the future either).

Each Git command can and does use whatever settings that program cares about. For instance, git commit needs your user.name and user.email settings, so that it can write the appropriate metadata into a new commit. The git branch command reads many of the branch.* settings, and may create some on its own for a new branch. The git remote command needs to read most of the [remote] section (various remote.* items); git push and git fetch will read some subset of them.

It's only upon reading some value that some command that uses the value will notice whether the value makes any sense to that particular command. So git init wants, for whatever reason, to use the core.safecrlf value, and reads out whatever core.safecrlf is set to, then demands that it be "boolean-able" (true, false, 0, 1, and empty all work here), or the special value warn.

The git config command is what creates, reads, and writes config files, so by design it tries not to depend on the configuration file: if the configuration file were required before the program that writes the configuration file can run, that would be a problem. It's like requiring that you be a member of some club before you can join. So git config does not depend on the core.safecrlf setting, and therefore cannot tell you if it's invalid. This is a bit of a flaw in the design, but it means that you can use git config to get or set nadin.data.why, even though Git has never heard of such a field.

  • Related