bash 全局 git 配置文件不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42053555/
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
global git config file does not exist
提问by Jesse van der Pluijm
git: git version 2.10.1 (Apple Git-78)
macOS: 10.12.3
git: git 版本 2.10.1 (Apple Git-78)
macOS: 10.12.3
I am (was) having some issues with git, everything committed locally and then pushed up to GitHub is (was) not referenced in my account but rather committed by an unknown user.
我(曾经)在使用 git 时遇到了一些问题,所有在本地提交然后推送到 GitHub 的内容都没有在我的帐户中引用,而是由未知用户提交。
I googled some online, as I always do, and came to this conclusion. The git config had been messed with. (Prev commits are fine etc.)
我像往常一样在网上搜索了一些,得出了这个结论。git 配置被弄乱了。(上次提交很好,等等)
Naturally I tried setting my email in the git config to match the one on GitHub, this way GitHub would automatically notice the (new) commits are mine and everything would be fine..
当然,我尝试在 git config 中设置我的电子邮件以匹配 GitHub 上的电子邮件,这样 GitHub 会自动注意到(新)提交是我的,一切都会好起来的。
So I ran
所以我跑了
git config --global user.email <[email protected]>
Without success... The following error was returned to me:
没有成功......以下错误返回给我:
error: could not lock config file /Users/<user>/.gitconfig: No such file or directory
I tried to reinstall/update git by downloading the latest version here.
我尝试通过在此处下载最新版本来重新安装/更新 git 。
Running git config --global -l
to list all of the configs returns the following error:
运行git config --global -l
以列出所有配置会返回以下错误:
fatal: unable to read config file '/Users/<user>/.gitconfig': No such file or directory
Conclusion
结论
The file does not seem to exist. As you can see in the screenshot. Reinstalling git via their website did not initiate the config file.
I have no clue what to do...
该文件似乎不存在。正如您在屏幕截图中看到的那样。通过他们的网站重新安装 git 并没有启动配置文件。
我不知道该怎么办...
Other posts:
I tried resolving this issue by going trough other related answers etc. However this did nothelp me resolve this issue. I think my case is a little more specific than most cases...
其他帖子:
我尝试通过其他相关答案等来解决这个问题。但这并没有帮助我解决这个问题。我认为我的情况比大多数情况更具体一些......
update
更新
回答by Harald Nordgren
Try
尝试
rm ~/.gitconfig
touch ~/.gitconfig
to remove the bad symlink and create a new config file.
删除错误的符号链接并创建一个新的配置文件。
Then re-run you command to create the setting:
然后重新运行你的命令来创建设置:
git config --global user.email <[email protected]>