8

Not sure if this is the correct place to post this problem, but:

When I try to do just about anything in my Git bash window, I get this error:

fatal: unknown error occured while reading the configuration files

Git error fatal unknown error occured while reading the configuration files

I tried several re-installs under different configurations and attempted numerous reboots to no help. I was questioning my username on Windows, since it has a dot (.) in it. Could that confuse Git for some reason? And if so: Is there a work-around?

I also cannot seem to locate where my config files are, since the command to find it is broken with the same error message.


I searched my computer for .gitconfig files. I found a total of 4 files:

  • C:\Program Files\Git\mingw64\etc\.gitconfig
  • C:\Program Files\Git\usr\share\vim\vim74\ftplugin\.gitconfig
  • C:\Program Files\Git\usr\share\vim\vim74\indent\.gitconfig
  • C:\Program Files\Git\usr\share\vim\vim74\syntax\.gitconfig

Here are the content of each file

...\Git\mingw64\etc.gitconfig

[credential]
helper = manager

...\Git\usr\share\vim\vim74\ftplugin.gitconfig

" Vim filetype plugin
" Language: git config file
" Maintainer:   Tim Pope <vimNOSPAM@tpope.org>
" Last Change:  2009 Dec 24

" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
  finish
endif
let b:did_ftplugin = 1

setlocal formatoptions-=t formatoptions+=croql
setlocal comments=:#,:; commentstring=;\ %s

let b:undo_ftplugin = "setl fo< com< cms<"

...\Git\usr\share\vim\vim74\indent.gitconfig

" Vim indent file
" Language: git config file
" Maintainer:   Tim Pope <vimNOSPAM@tpope.org>
" Last Change:  2013 May 30

if exists("b:did_indent")
  finish
endif
let b:did_indent = 1

setlocal autoindent
setlocal indentexpr=GetGitconfigIndent()
setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F

let b:undo_indent = 'setl ai< inde< indk<'

" Only define the function once.
if exists("*GetGitconfigIndent")
  finish
endif

function! GetGitconfigIndent()
  let line  = getline(prevnonblank(v:lnum-1))
  let cline = getline(v:lnum)
  if line =~  '\\\@<!\%(\\\\\)*\\$'
    " odd number of slashes, in a line continuation
    return 2 * &sw
  elseif cline =~ '^\s*\['
    return 0
  elseif cline =~ '^\s*\a'
    return &sw
  elseif cline == ''       && line =~ '^\['
    return &sw
  else
    return -1
  endif
endfunction

Git\usr\share\vim\vim74\syntax.gitconfig

" Vim syntax file
" Language: git config file
" Maintainer:   Tim Pope <vimNOSPAM@tpope.org>
" Filenames:    gitconfig, .gitconfig, *.git/config
" Last Change:  2010 May 21

if exists("b:current_syntax")
  finish
endif

setlocal iskeyword+=-
setlocal iskeyword-=_
syn case ignore
syn sync minlines=10

syn match   gitconfigComment    "[#;].*"
syn match   gitconfigSection    "\%(^\s*\)\@<=\[[a-z0-9.-]\+\]"
syn match   gitconfigSection    '\%(^\s*\)\@<=\[[a-z0-9.-]\+ \+\"\%([^\\"]\|\\.\)*"\]'
syn match   gitconfigVariable    "\%(^\s*\)\@<=\a\k*\%(\s*\%([=#;]\|$\)\)\@=" nextgroup=gitconfigAssignment skipwhite
syn region  gitconfigAssignment  matchgroup=gitconfigNone start=+=\s*+ skip=+\\+ end=+\s*$+ contained contains=gitconfigBoolean,gitconfigNumber,gitConfigString,gitConfigEscape,gitConfigError,gitconfigComment keepend
syn keyword gitconfigBoolean true false yes no contained
syn match   gitconfigNumber  "\d\+" contained
syn region  gitconfigString  matchgroup=gitconfigDelim start=+"+ skip=+\\+ end=+"+ matchgroup=gitconfigError end=+[^\\"]\%#\@!$+ contained contains=gitconfigEscape,gitconfigEscapeError
syn match   gitconfigError  +\\.+    contained
syn match   gitconfigEscape +\\[\\"ntb]+ contained
syn match   gitconfigEscape +\\$+    contained

hi def link gitconfigComment        Comment
hi def link gitconfigSection        Keyword
hi def link gitconfigVariable       Identifier
hi def link gitconfigBoolean        Boolean
hi def link gitconfigNumber     Number
hi def link gitconfigString     String
hi def link gitconfigDelim      Delimiter
hi def link gitconfigEscape     Delimiter
hi def link gitconfigError      Error

let b:current_syntax = "gitconfig"

I run Windows 7 x64 Professional. The computer is part of a domain network.

I Googled this problem and gave up when I came to page 11 with nothing useful.

Alexander Johansen
  • 522
  • 1
  • 14
  • 28
  • Do you have some known good .gitconfig files? If so try doing a `diff` between them to see if something is different. – kylieCatt Jul 15 '16 at 07:11
  • All the vim configurations files are not of interest. As for Git for Winfdows, there is also "C:\ProgramData\Git\config" and a `.gitconfig` or a `.config\git\config` in your userprofile directory. One of these files isn't readable - generally there should be no need to run git as administrator. – MrTux Jul 15 '16 at 07:27
  • I'd suggest to run procmon and watch for read or permission denied errors. – MrTux Jul 18 '16 at 16:23

10 Answers10

6

for me the issue was .gitconfig folder/dir in Users// deleting the dir(.gitconfig) resolved the issue and it's working fine now. click on this link to refer the image for solution

chuha.billi
  • 159
  • 1
  • 6
2

I ran into this same issue with Git installed on a machine that was part of a domain network. I followed the instructions listed in the first section of this post for creating a $HOME environment variable on my machine under my user profile, and it corrected the problem.

The issue was that our group policy set the home directory to be a location on the network. Git for Windows is configured to use the home directory by default for several settings, and some settings change on the network or my machine (who knows what) broke permissions to config files that had been created in this networked location that Git needed in order to function.

Try this:

  1. Run Git Bash as administrator.
  2. Do echo $HOME, and note the directory printed.
  3. Close Git Bash and run it not as administrator.
  4. Do echo $HOME, and compare the directory to the one printed when run as administrator.
  5. If the directories printed in steps (2) and (4) are different, follow the instructions in the linked blog post to set your $HOME environment variable to the directory printed when you ran Git Bash as administrator.
gooberwonder
  • 864
  • 1
  • 9
  • 16
1

Ok. So I found the solution, and it is embarrassingly simple!

All you need to do is run git-bash.exe as administrator.

I went into C:\Program Files\Git and set git-bash.exe to always run as administrator. That way I can still use my right-click shortcut and have it run as administrator automatically.

Right-click the git-bash.exe file and choose properties. Go under the compatibility tab and check the checkbox at the bottom that says "Run this program as administrator". Click OK, and problem should be solved.

Alexander Johansen
  • 522
  • 1
  • 14
  • 28
  • Please explain downvote? This might come useful for people who might encounter the same issue. – Alexander Johansen Jul 15 '16 at 07:27
  • There is generally no need to run git as Administrator (except you want to set system config). This just indicates that with your setup something is broken. – MrTux Jul 15 '16 at 07:30
  • @MrTux Honestly though: Is it really such a problem to run Git as administrator? The main idea is that it works. And that is all that I asked for. So I can continue to work on my projects. – Alexander Johansen Jul 15 '16 at 07:38
  • Confirm: running as admin is not needed. Disabling UAC is worse. Again: try again in a session started with a git unzipped (not installed) in `C:\git 2.9.0`? Unzip https://github.com/git-for-windows/git/releases/download/v2.9.0.windows.1/PortableGit-2.9.0-64-bit.7z.exe. Then `set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\git 2.9.0;C:\git 2.9.0\bin;C:\git 2.9.0\cmd;C:\git 2.9.0\usr\bin`. Try again in a CMD where that simpler `PATH` is set. – VonC Jul 15 '16 at 08:08
  • @VonC I tried this: I still get the same error message though. – Alexander Johansen Jul 15 '16 at 12:50
  • @AlexanderJohansen How about trying it in a simple CMd (with PATH set), without bash? – VonC Jul 15 '16 at 13:04
  • @VonC That's exactly what I did – Alexander Johansen Jul 15 '16 at 13:05
  • @AlexanderJohansen You mean, in that CMD, with that git 2.90 and a minimal path, `git config` *still* answer "unknown error when reading configuration file"? – VonC Jul 15 '16 at 13:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117416/discussion-between-alexander-johansen-and-vonc). – Alexander Johansen Jul 15 '16 at 13:07
  • @VonC I get the same error message in regular CMD, with all the path variables set. And running from `C:\git 2.9.0` – Alexander Johansen Jul 15 '16 at 13:11
0

That error message was seen in "Where does git config --global get written to?"

The problem was a second .gitconfig in this folder:

C:\Users\myUser.config\git\config

Minor nitpick, that error message will change with Git 2.9.x/2.10 (Q3 2016)

See commit 3a39f61, commit dc72b50 (10 Jun 2016) by Peter Colberg (``).
(Merged by Junio C Hamano -- gitster -- in commit 9d3d0db, 06 Jul 2016)

config.c: fix misspelt "occurred" in an error message

-       die(_("unknown error occured while reading the configuration files"));
+       die(_("unknown error occurred while reading the configuration files"));
                                 ^^
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • No such folder exists on my system. It also still doesn't work even if I try to create that file manually. – Alexander Johansen Jul 15 '16 at 06:42
  • @AlexanderJohansen OK. I was just mentioning the upcoming change in error message. – VonC Jul 15 '16 at 06:49
  • @AlexanderJohansen Can you try again in a session started with a git unzipped (not installed) in C:\git 2.9.0? Unzip https://github.com/git-for-windows/git/releases/download/v2.9.0.windows.1/PortableGit-2.9.0-64-bit.7z.exe. Then `set PATH=`C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\git 2.9.0;C:\git 2.9.0\bin;C:\git 2.9.0\cmd;C:\git 2.9.0\usr\bin`. Try again in a CMD where that simpler PATH is set. – VonC Jul 15 '16 at 06:54
  • @AlexanderJohansen Let's continue here. Just to check, can you create a user foo, switch to it, and see if that works better (to rule out your name and its dot) – VonC Jul 15 '16 at 13:13
0

Check for C:\users\mylogin.gitconfig if you dont find here go to C:\user\myLogin.git.gitconfig and see if it has Read permission to You, Give full control for you in security .

0

Had the same problem. Running as admin helped, so I have deleted all the .gitconfig files I was able to find on my computer and it helped

bora
  • 1
  • 1
0

I had the same error, and my issue was that my .config file in

c:\users\myLogin\.gitconfig

was empty. I added the following:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = <url>
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

Are any of your gitconfig files empty?

zx485
  • 28,498
  • 28
  • 50
  • 59
0

I am using Git on Windows and had the same problem, I deleted the .git-credentials and .gitconfig files and restarted Git and everything worked fine.

For me, the files were located in Documents folder in Windows.

You might have to add a few configurations again like user.name and user.email etc.

Ali
  • 7,810
  • 12
  • 42
  • 65
0

None of the options provided above worked for me. What finally fixed it was setting the HOME environment variable to point to something reasonable. Once this was done, git started behaving properly again.

Vivek Iyer
  • 364
  • 1
  • 4
-3

I had the exact same problem and it was even not solved after a complete re-install of git.

To solve this, create an empty .gitconfig file in:

C:\Users\<username>\AppData\Local\

I hope it has helped you.