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?
Come for the products,
stay for the community
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
4,468,041
Community Members
- Community
- Products
- Bitbucket
- Questions
- Can’t get past error message when trying to git global config username
Trying to configure global user name and email but keep getting the same error message:
- error: key does not contain a section: name
- error: key does not contain a section: email
What am I missing?
I’m on a Macbook Air (Mojave) using Terminal.
3 answers
1 accepted
Check the contents of the file:
cat ~/.gitconfig
The format should look something like:
[user]
name = Firstname Lastname
email = name@example.com
[core]
etc....
As @Jobin Kuruvilla [Adaptavist] suggested, it might be malformed and need manual updating.
You must be a registered user to add a comment. If you’ve already registered, sign in. Otherwise, register and sign in.
- Comment
There were some lines that I had to delete in the gitconfig file (i.e. two empty, two with an outdated username and email).
Thank you!
You must be a registered user to add a comment. If you’ve already registered, sign in. Otherwise, register and sign in.
- Comment
You must be a registered user to add a comment. If you’ve already registered, sign in. Otherwise, register and sign in.
- Comment
[user] + [core]
# inner local project$ vim .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true[user]
name = xgqfrms
email = xgqfrms@ufo.com$ cat .git/config
You must be a registered user to add a comment. If you’ve already registered, sign in. Otherwise, register and sign in.
- Comment
$ vim ~/.gitconfig # email = xgqfrms@ufo.com # name = xgqfrms [user] email = xxx@xxx.com name = xgqfrms $ cat ~/.gitconfig
You must be a registered user to add a comment. If you’ve already registered, sign in. Otherwise, register and sign in.
- Comment
Suggest an answer
Still have a question?
Get fast answers from people who know.
Was this helpful?
Thanks!
Atlassian Community Events
- FAQ
- Community Guidelines
- About
- Privacy policy
- Terms of use
- © 2023 Atlassian
Я недавно перенес git-репозиторий в новую организацию. Я запустил следующее:
git remote set-url origin https://github.com/organizationname/therepo.git
Я успешно тяну / толкаю с нового места. Но теперь я получаю следующие ошибки каждый раз, когда я запускаю команду git:
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
Сначала я думал, что это связано с моим файлом конфигурации, однако эти поля присутствуют. Первые строки файла My /.git/config
выглядят так:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
В этом ответе предлагается проверить --get-regex
, но Я не вижу ссылки на это в моих файлах конфигурации или .gitconfig
. Похоже, у меня есть 2 файла конфигурации git:
/usr/local/git/etc/gitconfig
И:
/Users/chmd/.gitconfig
Я попытался добавить эти ключи в файл /Users/chmd/.gitconfig
безуспешно. Какой шаг мне не хватает, чтобы убрать эти ошибки? Судя по предыдущему ответу и исследованию, похоже, это мой конфиг, но я включаю эти поля в свой gitconfig?
4 ответа
Лучший ответ
Действительно, проблема в .git/config
. Вы, вероятно, отредактировали его и по ошибке удалили название раздела.
Значения в конфигурационном файле Git сгруппированы по разделам. Название каждого раздела помещается в квадратные скобки на отдельной строке.
Отправленные вами значения (с начала вашего .git/config
) должны оставаться в разделе core
. Сделайте ваш .git/config
файл похожим на:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
...
13
axiac
18 Июл 2017 в 18:18
Это не ваш случай, но я отвечаю здесь за других людей с той же проблемой, что и я. У меня было это сообщение об ошибке:
error: key does not contain a section: name
error: key does not contain a section: email
Оказывается, я что-то напутал в моем ~/.gitconfig
файле.
Чтобы исправить это, я посмотрел этот пример и понял, что первый раздел этого файла должен выглядеть следующим образом это (поддельные данные примера):
[user]
name = Bart S
email = bart.s@example.com
username = barts
Это исправило это для меня.
0
Bart S
3 Июн 2020 в 19:53
вставьте следующий код в терминал, он откроет глобальный файл конфигурации в текстовом редакторе VI
git config --global --edit
Нажмите i, чтобы написать в текстовом редакторе VI, удалить весь текст и вставить следующее
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
Чтобы сохранить в VI нажмите ESC и: wq и нажмите ввод
4
khem raj regmi
13 Сен 2018 в 11:39
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
# ...
на прагматическое руководство по GIT имеет следующее: «Git использует оба для вычисления идентификатора фиксации-хэша SHA-111, который идентифицирует каждую фиксацию.»на странице 21.
и на странице 22, можно использовать следующую команду, чтобы настроить Git, чтобы знать, кто вы’.
git config --global smcho "Your Name"
когда я запустил его, я получил следующее сообщение об ошибке.
error: key does not contain a section: smcho
что в этом плохого? Я думаю, это имеет какое-то отношение к хэшу SHA-111, но я не знаю, как его использовать с гитом.
добавил
Я думал, пользователь.имя должно быть заменено моим именем, а не структурированным именем раздела/параметра. После изменения это работает нормально.
git config --global user.name "Your Name"
5 ответов
не уверен, откуда «smcho», но установка для установки вашего имени user.name
:
git config --global user.name "Your Name"
вы также можете установить свой адрес электронной почты:
git config --global user.email "name@domain.example"
Я думаю, причина, по которой он жалуется на отсутствие раздела, заключается в том, что имя параметра для установки, вероятно, должно быть в двух частях: section.parameter_name
(вы можете увидеть имена разделов в []
если вы посмотрите в файле конфигурации, например в .git/config
).
(ничто из этого не является специфичным для OSX как мне известно.)
простой ответ на этот вопрос/проблему заключается в том, что не заменяйте «пользователь».имя » с вашим фактическим именем пользователя git оставьте пользователя.имя как оно есть
команда должна быть:
git config --global user.name "Your Name here only"
редактировать весь файл config
git config --global --edit
эта ошибка потому, что у вас есть это слово (smcho) в начале вашего .файл gitconfig в домашнем каталоге.
поздновато, но может быть кому-то полезной.
error: key does not contain a section:
эта ошибка возникает, если вы не находитесь в каталоге git. Для работы команды config необходимо находиться в каталоге 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
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?
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?
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
...