4

Prior questions like Can't use git: "git fatal: unknown error occurred while reading the configuration files" talk about this error message:

G:\dev\some-repo> git status
fatal: unknown error occurred while reading the configuration files

…and answers go through various basic troubleshooting around finding config files, making sure those paths aren't directories, etc.

I've verified that my C:\Users\chas\.gitconfig file is a file, and aside from that, all the configuration files can be read as far as I can tell -- or, at least, I see values from all of the locations I'm aware of:

$ git config -l --show-origin
fatal: error processing config file(s)
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        core.symlinks=false
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        core.autocrlf=true
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        color.diff=auto
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        color.status=auto
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        color.branch=auto
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        color.interactive=true
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        pack.packsizelimit=2g
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        help.format=html
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        http.sslcainfo=/ssl/certs/ca-bundle.crt
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        diff.astextplain.textconv=astextplain
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        rebase.autosquash=true
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        filter.lfs.clean=git-lfs clean -- %f
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        filter.lfs.smudge=git-lfs smudge -- %f
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        filter.lfs.process=git-lfs filter-process
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        filter.lfs.required=true
file:"G:\\Downloads\\Git\\mingw64/etc/gitconfig"        credential.helper=manager
file:C:/Users/chas/.gitconfig   user.name=Chas Emerick
file:C:/Users/chas/.gitconfig   user.email=chas@cemerick.com
file:C:/Users/chas/.gitconfig   push.default=matching

Note:

  • fatal: error processing config file(s) message preceding all of the config entries
  • All of the above happens whether I'm in a repo or not
  • that my user-level file appears to be getting consumed properly
  • removing C:\Users\chas\.gitconfig entirely does not resolve the problem
  • The listing above is from using a self-contained/"portable" git executable/environment and using git-bash; the same problem persists when git is installed, and using git-bash from there, or git via cmd.exe.
  • Git version: 2.15.0; Windows 10 Pro, version 1709, OS build 16299.19

Help?

cemerick
  • 5,916
  • 5
  • 30
  • 51
  • Which version of `git` / `git-bash` are you using? – Yannoff Nov 12 '17 at 21:38
  • I should have said. I had been using an installed git that was somewhat older; in the course of attempting to diagnose the problem, I uninstalled that, and tried the "portable"/self-contained 2.15.0. Both versions have the same issue. – cemerick Nov 13 '17 at 01:41
  • However `G:\\Downloads\\Git\\mingw64/etc/gitconfig` seems a very strange path, even for `git-bash`, you should have something like `/etc/gitconfig` instead – Yannoff Nov 13 '17 at 07:43
  • What is the contents of the `.git/config` in that repository? – Edward Thomson Nov 13 '17 at 09:07
  • @yannoff that's why it's self-contained – Edward Thomson Nov 13 '17 at 09:08
  • @EdwardThomson The problem exists whether I'm in a repo or not. – cemerick Nov 13 '17 at 10:54
  • Try removing/checking the gitconfig file under the git installation folder as well. Basically, check every config file listed as a source for one or more configuration entries when you do `git config --list --show-origin`. – Lasse V. Karlsen Nov 13 '17 at 10:57
  • @LasseVågsætherKarlsen Good idea. No change though; `git config -l --show-origin` now produces no output at all, _except_ for `fatal: error processing config file(s)`. – cemerick Nov 13 '17 at 11:03
  • That seems correct because I assume one of the config files it tries to read is so corrupt that nothing is actually obtained from it, therefore the only thing it produces is that error message. Have you checked the [help page](https://git-scm.com/docs/git-config) for information about which config files it looks at? – Lasse V. Karlsen Nov 13 '17 at 11:27
  • @LasseVågsætherKarlsen I believe I've been comprehensive. I removed `$HOME/.gitconfig` and `/etc/gitconfig`, I'm not in a repo, and `$XDG_CONFIG_HOME` isn't set, so the config file there doesn't exist. – cemerick Nov 13 '17 at 12:06

1 Answers1

2

Double-check if

  • the error persists when using git config -l --show-origin outside of any git repo (in which case that might be related to the local repo you are in)
  • the error persists when using a simplified PATH (to rule out any other program side-effect)

There should 3 files (in addition to a possible local repo config file):

file:"C:\\ProgramData/Git/config"                     core.symlinks=false
...
file:"C:\\prgs\\git\\latest\\mingw64/etc/gitconfig"   core.symlinks=false
...
file:C:/Users/VonC/.gitconfig                         core.autocrlf=false

Or at least, the first one (C:\\ProgramData) should not point to a non-existent file.
See more at "Windows-specific Git configuration settings; where are they set?".
The page "Getting Started - First-Time Git Setup" mentions:

On Windows systems, Git looks for :

  • the .gitconfig file in the $HOME directory (C:\Users\$USER for most people).
  • It also still looks for /etc/gitconfig, although it’s relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer.
  • If you are using version 2.x or later of Git for Windows, there is also a system-level config file at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer.
    This config file can only be changed by git config -f <file> as an admin.

See git-for-windows/git commit 153328b, regarding the discussion between the libgit2 and the Git for Windows project, on how they could share Git configuration to avoid duplication (or worse: skew).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yeah, the problem exists whether I'm in a repo or not. – cemerick Nov 13 '17 at 10:54
  • Reasonable suggestion re: PATH. I set it to `C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem`. `git init` yields `fatal: unknown error occurred while reading the configuration files`; `git config -l --show-origin` prints `fatal: error processing config file(s)`. – cemerick Nov 13 '17 at 11:00
  • @cemerick Is it possible one of the config file is in CRLF instead of LF? Can yuo try and move those two config files and replace them by empty files, just to see if the error message persists? – VonC Nov 13 '17 at 11:58
  • as noted in the comments on the question, I've removed all cited config files, and the error persists. – cemerick Nov 13 '17 at 12:08
  • 1
    @cemerick That is my point: that is not *all* the config files. The `C:/ProgramData/Git/config` is missing – VonC Nov 13 '17 at 12:10
  • `/c/ProgramData/Git/config` is a link to `/c/.gitconfig`, which doesn't exist. – cemerick Nov 13 '17 at 12:20
  • 1
    @cemerick And that might be your issue right there. On my workstation, it is not a link but an actual file. – VonC Nov 13 '17 at 12:21
  • Whoa -- that was it, I think: removed the symlink at `/c/.gitconfig`, and all's well! I have _no_ idea where that came from though, as I'm never on C: at all anyway, nevermind putting a .gitconfig at a drive root........ – cemerick Nov 13 '17 at 12:22
  • 1
    @cemerick Great! I have edited the answer to make that missing third file more visible. – VonC Nov 13 '17 at 12:25
  • Thank you for your help! I'm still thoroughly puzzled as to how a link got there, though. All my work happens over on G: via lxss, and I wasn't particularly aware of `C:\ProgramData` before this. ᖍ(ツ)ᖌ – cemerick Nov 13 '17 at 15:20