Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

github - Git Error - key does not contain a section

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

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

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

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

and:

/Users/chmd/.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Indeed, the problem is in .git/config. You probably edited it and you removed the name of the section by mistake.

The values in Git config file are grouped in sections. The name of each section is placed between square brackets on a separate line.

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
    ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...