在 git shell 中,GitHub 错误“致命:.git/config 中的配置文件第 1 行错误”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27073427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GitHub error "fatal: bad config file line 1 in .git/config" when in git shell
提问by Dom
Im using GitHub on Windows and after working fine for the whole time, when I opened it today, it says:
我在 Windows 上使用 GitHub,并且在一直工作正常后,今天打开它时,它说:
Failed to load commit history for this repository. You might need to open a shell and debug the state of this repo.
无法加载此存储库的提交历史记录。您可能需要打开一个 shell 并调试此 repo 的状态。
And then:
进而:
Failed to get list of branches.
无法获取分支列表。
When I open shell and try git status
or whatever other command, it returns this error :
当我打开 shell 并尝试git status
或任何其他命令时,它返回此错误:
fatal: bad config file line 1 in .git/config
致命:.git/config 中的错误配置文件第 1 行
Not sure what to do with that? I read someone saying to replace the config file with an earlier version of it, but I dont have an earlier version..
不知道该怎么办?我读到有人说要用它的早期版本替换配置文件,但我没有早期版本..
回答by Dom
My question might have been abit vague, but I wasnt sure myself what happened. I solved it by finding .git/config file on my laptop using Windows search , and deleting it. Then I deleted content of my github folder and cloned the repo again and it worked after :)
我的问题可能有点含糊,但我不确定自己发生了什么。我通过使用 Windows 搜索在我的笔记本电脑上找到 .git/config 文件并删除它来解决它。然后我删除了我的 github 文件夹的内容并再次克隆了 repo,它在 :)
回答by Issaka Faisal
I solved this by
我解决了这个问题
- open .git/config file
- clear all the NULL values in the file
- save and close the file
- git add .
- 打开 .git/config 文件
- 清除文件中的所有 NULL 值
- 保存并关闭文件
- git 添加。
回答by Pratik N
I solved this on my mac by
我在我的 mac 上解决了这个问题
- created a .gitconfig file in $HOME(cmd + shift + h) folder
- added
[user] name = myname email = [email protected]
in the .gitconfig file - saved and replaced with the existing file
- 在 $HOME(cmd + shift + h) 文件夹中创建了一个 .gitconfig 文件
- 添加
[user] name = myname email = [email protected]
到 .gitconfig 文件中 - 保存并替换为现有文件
now all git commands started working
现在所有 git 命令都开始工作了
回答by Tayfun Ka?ar
I had got same problem and i removed the .gitconfig file from local repository .The prroblem is resolved.
我遇到了同样的问题,我从本地存储库中删除了 .gitconfig 文件。问题解决了。