一、 问题描述
git在 pull/push 代码的时候提示:The Requested URL return error 403,这表示我们没有权限来pull/push相关代码
二、 问题分析
- 有可能你是真的没有权限(认真脸)
- 你修改了
git仓库的用户名和密码,导致你内存和硬盘中缓存的账号密码不能使用
三、问题处理
方案1:
1、执行git config --list,查看git的配置信息

gitconfig.png
图中红色部分内容
[user]为你的git账号配置信息,[credential]为你的这些信息存储位置
2、执行vim .git-credentials,查看credential中缓存的账户

credential.png
2、 执行git help -a | grep credential,查看git的信息存储位置

cache.png
git help -a | grep credential命令查看自己系统支持的crendential,cache代表内存中的缓存,store代表磁盘。git config credential.helper命令可以看到cache、store、osxkeychain(钥匙串)中是否还有git的配置信息。由图中我们可以得出git config还存储在store中
3、一般配置方法:
git config --global (--replace-all) user.name "你的用户名"git config --global (--replace-all) user.email "你的邮箱"
4、如果上述步骤没有效果,我们就需要清除缓存(.gitconfig)
git config --local --unset credential.helpergit config --global --unset credential.helpergit config --system --unset credential.helper
具体介绍可以查看这里, 可能有多处
.gitconfig文件
四、 重复输入用户名密码
清除缓存之后我们每次提交代码的时候都需要输入用户名和密码
git config --global credential.helper store
或者
-
执行修改
.gitconfig配置文件,把以下内容放置到最后[credential] helper = store -
执行
vim .gitconfig查看
作者原文:Git The requested URL returned error: 403
方案2:
直接在本地计算机修改或者删除凭证即可:控制面板 / 所有控制面板项 / 凭据管理器

1万+

被折叠的 条评论
为什么被折叠?



