Git - 致命:读取配置文件时发生未知错误

Ale*_*sen 6 git

不确定这是否是发布此问题的正确位置,但是:

当我尝试在我的Git bash窗口中执行任何操作时,我收到此错误:

fatal: unknown error occured while reading the configuration files
Run Code Online (Sandbox Code Playgroud)

读取配置文件时发生Git错误致命未知错误

我在不同的配置下尝试了几次重新安装,尝试了多次重启,没有任何帮助.我在Windows上质疑我的用户名,因为它里面有一个点(.).由于某些原因,这会让Git感到困惑吗?如果是这样的话:有没有解决方法?

我似乎无法找到我的配置文件的位置,因为找到它的命令被破坏了相同的错误消息.


我在电脑上搜索.gitconfig文件.我发现了总共4个文件:

  • 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

以下是每个文件的内容

... \的Git\mingw64\etc.gitconfig

[credential]
helper = manager
Run Code Online (Sandbox Code Playgroud)

... \混帐的\ usr \共享\ 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<"
Run Code Online (Sandbox Code Playgroud)

... \混帐的\ usr \共享\ 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
Run Code Online (Sandbox Code Playgroud)

混帐的\ usr \共享\ 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"
Run Code Online (Sandbox Code Playgroud)

我运行Windows 7 x64 Professional.计算机是域网络的一部分.

我用Google搜索了这个问题,当我第11页没有任何用处时放弃了.

chu*_*lli 6

对我来说,问题是用户中的 .gitconfig 文件夹/目录// 删除目录(.gitconfig)解决了这个问题,现在工作正常。 单击此链接以参考图像以获取解决方案


Ale*_*sen 1

好的。所以我找到了解决方案,而且非常简单!

您所需要做的就是以管理员身份运行git-bash.exe

我进入C:\Program Files\Git并设置git-bash.exe为始终以管理员身份运行。这样我仍然可以使用右键单击快捷方式并让它自动以管理员身份运行。

右键单击该git-bash.exe文件并选择属性。转到“兼容性”选项卡,然后选中底部的“以管理员身份运行此程序”复选框。单击“确定”,问题应该得到解决。