环境
操作系统:Ubuntu20.04
git版本: 2.25.1
故障描述
在ubuntu服务器上突然无法使用git clone命令,提示如下错误:
[root@3fdev ~]git clone http://username:password@x.x.x.x:9000/test-project/test-project.git
Cloning into 'test-project'...
remote: Forbidden
fatal: unable to access 'http://x.x.x.x:9000/test-project/test-project.git/': The requested URL returned error: 403
排查步骤
1、排查了网络没问题;
2、访问项目的权限;
3、在其他服务器上安装git,能正常clone代码。
解决办法
经过排查发现~/.gitconfig文件不存在,所以使用如下命令生成:
[root@3fdev ~]git config --global user.name "yourname"
[root@3fdev ~]git config --global user.email "your_email"
结果
再次使用git clone 就能正常使用。