Windows环境下解决 github push failed (remote: Permission to userA/XXXX.git denied to userB.)

· 初学GitHub的朋友遇到可能会遇到一些很难找到答案的问题,这个就是一个找了3天才有点眉目的问题,现在把解决方法分享给大家,希望初学者少走弯路。

下面假设了两个用户 userA 和 userB ,userA的github项目名为 XXXX.git

----------------------------------------------------------------------------------------------------------------------------------------------------- 
针对git push的时候报错(解决上传到github报错)
Successfully created project 'XXXX' on GitHub, but initial commit failed:
remote: Permission to userA/xxxx.git denied to userB。fatal: unable to access ‘https://github.com/userA/xxxx.git/‘: The requested URL returned error: 403
-----------------------------------------------------------------------------------------------------------------------------------------------------

当你在使用Idea、VS code 、Android Studio等开发工具 push项目的时候,如果遇到了这个问题:

fatal: unable to access 'https://github.com/userA/XXXX.git/': The requested URL returned error: 403

问题的表面原因?

报了403,说明访问被拒绝。 
切换到终端(Terminal),使用命令 git push -u origin master 后,错误显示到下方了:

remote: Permission to userA/repo.git denied to userB.
fatal: unable to access 'https://github.com/userA/XXXX.git/': The requested URL returned error: 403

问题分析

意思很明显,就是说userB没有权限对userA的XXXX仓库进行push更改。

  • A) 可以通过shell命令(打开Git Bash程序)输入  cat ~/.gitconfig ,得知当前的用户为userB。
  • B) 也可以

这时你早已经使用如下命令去配置过全局用户:

git config --global user.name "userA"
git config --global user.email "userA@Email.com"

并且很明确当前用户已经是userA,但还是说userB没权限。
那么究竟是什么原因呢? 
由于该电脑使用git bash配过SSH,系统已经将指向github.com的用户设置为了userB,每次push操作的时候,都将读取到userB的用户信息,类似于记住密码。

如何解决?

三种方案:
1、对userA生成SSH公钥,添加到userB的github后台; 
2、将userB添加为userA项目的contributer; 
3、移除计算机中的userB。

对于1和2,相信很多人不想这么做,因为一旦使用了SSH,以后的所有clone、pull、push等操作都将使用SSH传输,对以往使用过https传输的项目也得重新更改传输方式,这样会浪费一些时间。

现在详细讲下方案3,操作很简单:

打开 控制面板–>用户账户–>凭据管理器–>管理Windows凭据(或者在开始菜单中搜索 【凭据管理器】)

打开凭据管理器后,下拉在普通凭证,展开这条github.com相关的凭据,直接删除 或者 点编辑修改,再拉取或者提交的时候会让我们重新输入用户名密码 。


好了,问题解决,现在去各类Studio开发平台 重新push上传代码到GitHub,要求你输入userA的邮箱和密码,输入后就可以成功提交了。

最后查看重新生成了一个证书,并且未指定用户。
---------------------

参考文献:

1. I-T枭   https://blog.csdn.net/hahahhahahahha123456/article/details/81104977

2. 神话2009 https://blog.csdn.net/klxh2009/article/details/76019742

·

·

Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错的更多相关文章

  1. github多用户git push错误remote: Permission to user1/z.git denied to user2

    背景:同一台电脑的public key同时添加到了github的两个账户,导致user1的仓库没法正常提交. 解决办法:为两个账户分别配置ssh key,配置~/.ssh/config文件(windo ...

  2. remote: Permission to user_name/Code.git denied to other_user_name. fatal: unable to access 'https://github.com/user_name/Code.git/': The requested URL returned error: 403

    Error msg: $ git push remote: Permission to xxx/Code.git denied to xxxxxx. fatal: unable to access ' ...

  3. git@github.com: Permission denied (publickey).////remote: Permission to xxx/test.git denied to xxx.等权限问题

    Error msg git@github.com: Permission denied (publickey) 或者: remote: Permission to xxx/test.git denie ...

  4. Nginx反向代理上传大文件报错(failed to load resource : net :: ERR_CONNECTION_RESET)

    转自: https://blog.csdn.net/kinginblue/article/details/50753271?locationNum=14&fps=1 Nginx反向代理上传大文 ...

  5. git上传文件夹报错: ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/taminachen/rjxm.git' hint: Updates were rejected because the remote contains work

    使用git上传本地文件夹到远程仓库,使用如下命令:git push -u origin master时报错 原因是在GitHub创建仓库时创建了readme文件,但是本地没有这个文件,造成本地目录与远 ...

  6. FTP上传文件,报错java.net.SocketException: Software caused connection abort: recv failed

    FTP上传功能,使用之前写的代码,一直上传都没有问题,今天突然报这个错误: java.net.SocketException: Software caused connection abort: re ...

  7. python用ftplib上传下载中文报错解决

    python中的中文编码一直以来都是一个极为头大的问题,经常抛出编码转换的异常,python中的str和unicode到底是一个什么东西呢?在python中提到unicode,一般指的是unicode ...

  8. SpringBoot 上传文件突然报错 Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608

    异常信息 org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request ...

  9. jquery上传插件uploadify 报错http error 302 解决方法之一

    前段时间用到jquery上传插件uploadify时,始终出现系统报出 http error 302 的错误. 网上大量搜集信息,基本上都是说session值丢失的问题,根据网友提供的解决方案进行修改 ...

随机推荐

  1. Hook 初学习

    Hook 概念 百度上的概念 每个Hook都有一个相关的指针列表,后加入的Hook再链表的开始,先加入的在链表的尾部 即后加入先获得控制权 Hook 原理 原本的流程 graph LR id1(Mes ...

  2. 三维重建(一):colmap安装与使用

    Image-based 3D Reconstruction from Scratch (using COLMAP) 本文将介绍COLMAP的安装与使用,重点介绍3D重建过程中每个步骤的输入输出. 一. ...

  3. Newtonsoft--自定义格式化日期

    public string ToJson(object obj, string timeFormat) { try { IsoDateTimeConverter timeConverter = new ...

  4. Supermarket POJ - 1456 贪心+并查集

    #include<iostream> #include<algorithm> using namespace std; const int N=1e5; struct edge ...

  5. LaTeX 技巧 802:国内期刊 CCT 模板编译经验

    国内有不少期刊依旧在使用过时的 CCT 方式来支持中文,这些模板非常相似,似乎系出同源.由于这些模板在现代的 TeX 发行版内无法正确编译,对不少投稿人造成困扰,所以我写下这篇文章,希望对投稿人有一些 ...

  6. 遇到的错误:Mysql 报错Duplicate entry '值' for key '字段名'的解决

    ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolatio ...

  7. mysql 数据备份。pymysql模块

    阅读目录 一 IDE工具介绍 二 MySQL数据备份 三 pymysql模块 一 IDE工具介绍 生产环境还是推荐使用mysql命令行,但为了方便我们测试,可以使用IDE工具 下载链接:https:/ ...

  8. 16G内存,将内存占用,降到了 40% 以下,之前是 90%+

    自定义组件:

  9. Give me five !

    @media only screen and (max-width: 360px) { #friedsGroup { grid-template-columns:1fr!important; } } ...

  10. C++ lambda函数及其用法(转)

    由于接触C++不久,很多东西比较陌生,今天看阿里云OSS的C++ SDK文件下载部分例子,发现有如下lambda表达式用法,故了解一下相关知识 /*获取文件到本地文件*/ GetObjectReque ...