Git错误-键不包含任何部分 [英] Git Error - key does not contain a section
问题描述
我最近将git存储库转移到了新的组织.我运行了以下内容:
I recently transferred a git repository to a new organization. I ran the following:
git remote set-url origin https://github.com/organizationname/therepo.git
我已成功从新位置拉/推.但是现在每次我运行git命令时都会遇到以下错误:
I am successfully pulling/pushing from the new location. But now getting the following errors every time I run a git command:
error: key does not contain a section: repositoryformatversion
error: key does not contain a section: filemode
error: key does not contain a section: bare
error: key does not contain a section: logallrefupdates
error: key does not contain a section: ignorecase
error: key does not contain a section: precomposeunicode
我最初以为它与我的配置文件有关,但是存在这些字段.我的/.git/config
文件的第一行如下:
I initially thought it had to do with my config file however those fields are present. The first lines of My /.git/config
file looks like this:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
在此答案中,建议检查--get-regex
但我在配置文件或.gitconfig
文件中看不到任何引用.看来我有2个git配置文件:
In this answer it suggests to check for --get-regex
but I do not see any reference to that in my config or .gitconfig
files. It looks like I have 2 git config files:
/usr/local/git/etc/gitconfig
和:
/Users/chmd/.gitconfig
我尝试将这些密钥添加到/Users/chmd/.gitconfig
文件中,但没有这种运气.我想清除这些错误还缺少什么步骤?根据先前的答案和研究,这似乎是我的配置,但是我在gitconfig中包括了这些字段吗?
I tried adding those keys to /Users/chmd/.gitconfig
file with no such luck. What step am I missing to clear out these errors? Based on previous answer and research it seems to be my config, but I'm including those fields in my gitconfig?
推荐答案
实际上,问题出在.git/config
中.您可能对其进行了编辑,并误删除了该部分的名称.
Indeed, the problem is in .git/config
. You probably edited it and you removed the name of the section by mistake.
Git配置文件中的值按部分分组.每个部分的名称放在方括号之间,并在一行上.
The values in Git config file are grouped in sections. The name of each section is placed between square brackets on a separate line.
您发布的值(从.git/config
开头)应保留在core
部分中.使您的.git/config
文件看起来像:
The values you posted (from the beginning of your .git/config
) should stay in the core
section. Make your .git/config
file look like:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
...
这篇关于Git错误-键不包含任何部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!