Git Error - key does not contain a section

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 = [email protected]
    username = barts

This fixed it for me.


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

Git configuration is organized in sections.

It's:

  • core.repositoryformatversion
  • core.filemode
  • color.ui
  • ...

Your .git/config should look like this:

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

Tags:

Git

Github