9

Just started working with git 15 minutes ago and already trouble ... damn.

Well, just as i wrote in the headline, im currently working with the git-scm book here: http://git-scm.com/book

In 2.1 - Getting a Git repository, it says:

If you’re starting to track an existing project in Git, you need to go to the project’s directory and type

$ git init

Thats exactly what im doing, but somehow, i get this error message here:

fatal: bad numeric config value 'auto' for 'core.autocrlf' in C:\Program Files 
(x86)\Git(etc/gitconfig: invalid unit

I configured everything just as it says in the book ... im kinda helpless here, especially because i got absolutely no experience with git and google doesnt seem to be very helpful in that case. ._.

Edit: Heres a screenshot, maybe it helps you:

._.

Realitätsverlust
  • 3,941
  • 2
  • 22
  • 46
  • 1
    Did you manually change the configuration for Git, or is the configuration file exactly what you got from an installer? –  Jan 24 '14 at 09:22
  • Its the config i got from the installer. I never executed a config statement for autocrlf or something like that. I just adjusted my name and e-mail. – Realitätsverlust Jan 24 '14 at 09:23
  • With a setting of "auto", I get the same error (well, I get "bad config value" instead of "bad numeric config value"), and the documentation doesn't give any indication that "auto" is a valid value, so if the installer does configure it like that, that seems like a problem with the installer. –  Jan 24 '14 at 09:34
  • Is manually changing the config file a problem? I have done for `[alias]` and `[color "status"]` within `~/.gitconfig` – heretoinfinity Apr 15 '20 at 18:57
  • 1
    No, it's really not a problem. ``git config`` does nothing else but edit the file, so you can do it yourself too. Just beware of typos, those are extremely hard to spot. – Realitätsverlust Apr 17 '20 at 08:16

4 Answers4

21

Try a

git config --system --unset core.autocrlf

I would then advise for a:

git config --global core.autocrlf false

(see "Why should I use core.autocrlf=true in Git?"; using core.eol settings per files is more precise than using a repo-wide global setting)

You could set it back in the system config if you want:

git config --system core.autocrlf false

But the main point is 'auto' isn't a valid value: true, false or input are, as detailed here.


FernandoZ suggests in the comments:

git config --global --replace-all core.autocrlf false
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is there a particular reason you recommend moving the setting from the system file to the per-user global file? –  Jan 24 '14 at 09:23
  • @hvd I have edited the answer to reference why I recommend *not* using that legacy dangerous `core.autocrlf` setting. – VonC Jan 24 '14 at 09:24
  • When i try the first statement, i get the error message `fatal: No such section!` But when i enter `git config --list`, its there. – Realitätsverlust Jan 24 '14 at 09:25
  • @VonC I don't mean whether a particular `core.autocrlf` value is a useful setting, I just mean I don't see why having `core.autocrlf = false` in the global config file is any better or worse than having `core.autocrlf = false` in the system config file, so I don't see why you removed it from the system config and added it to the global config. –  Jan 24 '14 at 09:28
  • BTW, as the error from Y U NO WORK indicates, `--remove-section` is the wrong option regardless, it should be `--unset`. `--remove-section` is for removing a whole section, such as `core`. –  Jan 24 '14 at 09:32
  • Alright, thanks a lot, `--unset` and the second query of VonC did the trick. `Initialized empty Git repository in y:/.git/`. :) – Realitätsverlust Jan 24 '14 at 09:36
  • @YUNOWORK I have edited the answer ti use unset, as hvd mentioned. – VonC Jan 24 '14 at 09:57
  • I was stuck unable to change this setting and ended up using – FernandoZ Jun 19 '18 at 16:22
  • 1
    git config --global --replace all core.autocrlf false – FernandoZ Jun 19 '18 at 16:22
  • 1
    @FernandoZ Thank you. I have included your comment in the answer for more visibility. It is `--replace-all`, not `--replace all`. – VonC Jun 19 '18 at 16:26
  • Maybe: git config --system --unset-all core.autocrlf – o0omycomputero0o Jul 24 '19 at 10:56
1

Commands from the console didn't help me. Opened 3 config files (local system global) and removed the problematic value. enter image description here

1
  1. go to repo folder
  2. open the .git folder
  3. open the file config
  4. remove duplicate entries
Ali Samie
  • 145
  • 2
  • 11
0

For me it worked this way:

git config --global commit.gpgsign false

IgorAlves
  • 5,086
  • 10
  • 52
  • 83