我最近将一个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
Run Code Online (Sandbox Code Playgroud)
我最初认为它与我的配置文件有关,但这些字段存在.My /.git/config文件的第一行如下所示:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
Run Code Online (Sandbox Code Playgroud)
在这个答案中它建议检查--get-regex但我在配置或.gitconfig文件中没有看到任何引用.看起来我有2个git配置文件:
/usr/local/git/etc/gitconfig
和:
/Users/chmd/.gitconfig
我尝试将这些密钥添加到/Users/chmd/.gitconfig文件中,没有运气.我错过了哪些步骤来清除这些错误?根据以前的答案和研究,它似乎是我的配置,但我在我的gitconfig中包含这些字段?
axi*_*iac 12
的确,问题在于.git/config.你可能编辑了它,你错误地删除了该部分的名称.
Git配置文件中的值按部分分组.每个部分的名称放在单独的方括号之间.
您发布的值(从您的开头.git/config)应保留在该core部分中.使您的.git/config文件看起来像:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
...
Run Code Online (Sandbox Code Playgroud)
将以下代码粘贴到终端,它将在 VI 文本编辑器中打开全局配置文件
git config --global --edit
Run Code Online (Sandbox Code Playgroud)
按 i 在 VI 文本编辑器中写入并删除所有文本并粘贴以下内容
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
Run Code Online (Sandbox Code Playgroud)
要保存在 VI 中,请按 ESC 和 :wq 并按 Enter
这不是你的情况,但在这里为其他与我有同样问题的人做出回应。我收到此错误消息:
error: key does not contain a section: name
error: key does not contain a section: email
Run Code Online (Sandbox Code Playgroud)
原来我把 ~/.gitconfig文件里的东西弄乱了。
为了解决这个问题,我查看了这个示例,并意识到该文件的第一部分应该如下所示(假示例数据):
[user]
name = Bart S
email = bart.s@example.com
username = barts
Run Code Online (Sandbox Code Playgroud)
这为我解决了这个问题。