【Git】fatal: unable to read config file `***/.gitconfig` No such file or director

2,586 阅读1分钟

小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。

🔥fatal

近日,新买了一台 ECS 云服务器,使用 CentOS 7.9 64位的操作系统,打算下载 docker 并基于 docker 容器搭载 hbase 集群,这时需要使用 git,执行如下命令下载 git:

$ yum -y install git

然后查看 git 版本:

$ git --version

虽然之前在 Windows 上下载过一次 git 工具了,但还是不长记性(忘记配置 git),直接使用 $ git config --global -l,果不其然出现了如下错误:

fatal: unable to read config file '%HOMEDRIVE%%HOMEPATH%/.gitconfig': No such file or directory

🔥reason

由提示信息可知,由于对应目录下 .gitconfig 文件不存在,从而导致该问题的出现!

🔥solve

⭐细想一下在 Windows 上的 git 安装,发现自己忘记了 git 初始化配置

$ git config --global user.name "你的用户名"
$ git config --global user.email "你的邮箱"
$ git config --global user.password "你的密码"

配置完以上信息即可使用 git 啦!

再次执行 git 命令查看:

$ git config --global -l

这下问题解决了!

Reference StackOverflow:stackoverflow.com/questions/5…


希望本文对你有所帮助🧠
欢迎在评论区留下你的看法🌊,我们一起讨论与分享🔥