Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Error - key does not contain a section

Tags:

git

github

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?

like image 304
kawnah Avatar asked Jul 18 '17 18:07

kawnah


People also ask

How do I fix author identity unknown in git?

When linking a commit to a Story, you may see "Unknown Author" in the Commit section. This indicates that the email address you used in your GitHub, GitLab, or Bitbucket account doesn't match the email address you used for your Shortcut account. To correct this: Go to Settings > Your Account > Email Addresses.

How do I edit Gitconfig?

How to do a git config global edit? The global git config is simply a text file, so it can be edited with whatever text editor you choose. Open, edit global git config, save and close, and the changes will take effect the next time you issue a git command. It's that easy.


1 Answers

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
    ...
like image 124
axiac Avatar answered Sep 18 '22 06:09

axiac