Git Error - key does not contain a section

Viewed 70103

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?

5 Answers

paste the following code to terminal it will open global config file in VI text editor

git config --global --edit

press i to write in VI text editor and remove all the text and paste the following

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true

to save in VI press ESC and :wq and press enter

This is not your case, but responding here for other people with the same issue as me. I had this error message:

error: key does not contain a section: name
error: key does not contain a section: email

It turns out I had messed up something in my ~/.gitconfig file.

To fix it, I looked at this example and realized the first section of that file should look like this (fake example data):

[user]
    name = Bart S
    email = bart.s@example.com
    username = barts

This fixed it for me.

git config [section] solutions

fix git [section] warnings

  1. global config
$ vim ~/.gitconfig

[user]
  email = xgqfrms@xgqfrms.xyz
  name = xgqfrms


$ cat ~/.gitconfig

  1. project local config
$ vim .git/config

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true

[user]
  name = xgqfrms
  email = xgqfrms@ufo.com
$ cat .git/config

demos

error: key does not contain a section: email
error: key does not contain a section: name

before

enter image description here

after

enter image description here

Related