美文网首页Git使用程序员Git
Git The requested URL returned e

Git The requested URL returned e

作者: Nickyzhang | 来源:发表于2017-11-29 13:16 被阅读44次

一、 问题描述

gitpull/push 代码的时候提示:The Requested URL return error 403,这表示我们没有权限来pull/push相关代码

二、 问题分析

  • 有可能你是真的没有权限(认真脸)
  • 你修改了git仓库的用户名和密码,导致你内存和硬盘中缓存的账号密码不能使用

三、问题处理

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命令可以看到 cachestoreosxkeychain(钥匙串)中是否还有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.helper
  • git config --global --unset credential.helper
  • git config --system --unset credential.helper

具体介绍可以查看这里, 可能有多处.gitconfig文件

四、 重复输入用户名密码

清除缓存之后我们每次提交代码的时候都需要输入用户名和密码
  • git config --global credential.helper store
或者
  • 执行修改.gitconfig配置文件,把以下内容放置到最后

      [credential]
              helper = store  
    
  • 执行 vim .gitconfig查看

    credential-help.png

本次问题到此结束,如有问题请留言

友情链接
关于credential的介绍可以点击这里
关于.gitconfig清除缓存可以点击这里

相关文章

网友评论

    本文标题:Git The requested URL returned e

    本文链接:https://www.haomeiwen.com/subject/vzuubxtx.html