Git错误--git remote: HTTP Basic: Access denied fatal: Could not read from remote repository.

mac2024-03-14  25

一、git安装成功后,clone时出现出错 1、 fatal: Could not read from remote repository. 2、HTTP Basic: Access denied

二、可能的原因: 1、SSH不对,更新ssh 2、是第一次输入账号密码时,出现错误,但是git又帮你记录下来了,每次都去读取错误的账户及密码。

三 、解决办法: 步骤 1、找到本地的gitconfig文件,清空 2、输入: $ git config --global user.name “输入你的用户名” $ git config --global user.email “输入你的邮箱”

四、解决每次clone需要输入用户名密码: 1、在Windows中添加一个HOME环境变量,值为%USERPROFILE% 2. 在“开始》运行”中打开%Home%【即‘桌面’文件夹所在目录】,新建一个名为“_netrc”的文件。 3. 用记事本打开_netrc文件,输入Git服务器名、用户名、密码,并保存。示例如下: machine git.xxx.com login user_name password user_pwd


参考: 0:

输入 $ git config --list

可以查看配置的一些东西。可以看到user.name 和user.email 分别是什么。。 如果你没有初始化过。那么直接: $ git config --global user.name “输入你的用户名” $ git config --global user.email “输入你的邮箱”

这样就可以初始化了。

1:

如果你已经初始化过了,但是不小心把邮箱和用户名输错了,那么就要修改了。 我看到网上有人说继续$ git config --global user.name "输入你的用户名"或者 $ git config --global user.email “输入你的邮箱” 来修改邮箱和密码。我尝试了一下,是不行的(至少在window10的环境下)会给出这样的错误: warning: user.name has multiple values error: cannot overwrite multiple values with a single value Use a regexp, --add or --replace-all to change user.name.

这边给出了–repalce-all 这个东西。

然后我尝试着用 $ git config --global --replace-all user.email “输入你的邮箱” $ git config --global --replace-all user.name “输入你的用户名”

然后再查看下 $ git config --list 发现修改成功了。


最新回复(0)