全局git配置文件不存在

时间:2017-02-05 15:04:42

标签: git bash macos-sierra git-config

git: git版本2.10.1(Apple Git-78)
macOS: 10.12.3

我在git上遇到了一些问题,在本地提交的所有内容然后推送到GitHub都是在我的帐户中没有引用,而是由未知用户提交。

我在网上搜索了一些,就像我一直这样,并得出了这个结论。 git配置已被搞砸了。 (上一次提交很好等。)

当然我尝试在git配置中设置我的电子邮件以匹配GitHub上的电子邮件,这样GitHub会自动注意到(新的)提交是我的,一切都会好的。

所以我跑了

git config --global user.email <my-email@email.com>

没有成功......我回复了以下错误:

error: could not lock config file /Users/<user>/.gitconfig: No such file or directory

我尝试通过下载最新版本here重新安装/更新git。

运行git config --global -l列出所有配置会返回以下错误:

fatal: unable to read config file '/Users/<user>/.gitconfig': No such file or directory

terminal screenshot

结论

该文件似乎不存在。正如您在屏幕截图中看到的那样。通过他们的网站重新安装git没有启动配置文件 我不知道该怎么做......

其他帖子
我尝试通过其他相关答案等来解决此问题。但是这确实帮我解决了这个问题。我认为我的案例比大多数案件更具体......

更新

试图创建文件夹: update screenshot

1 个答案:

答案 0 :(得分:7)

尝试

rm ~/.gitconfig
touch ~/.gitconfig

删除错误的符号链接并创建新的配置文件。

然后重新运行命令以创建设置:

git config --global user.email <my-email@email.com>
相关问题