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. cf912D

    题意简述:往n*m的网格中放k条鱼,一个网格最多放一条鱼,然后用一个r*r的网随机去捞鱼,问怎么怎么放鱼能使得捞鱼的期望最大,输出这个期望 题解:肯定优先往中间放,这里k不大,因此有别的简单方法,否则 ...

  2. 安装Nexus到Linux(源码)

    运行环境 系统版本:CentOS Linux release 7.4.1708 (Core) 软件版本:Sonatype-Nexus-3.14.0 硬件要求:无 安装过程 1. 调整系统参数 需要调整 ...

  3. windows2016_x64搭建ELK(datasource->filebeat->logstash->elasticsearch->kibana)

    windows2016_x64搭建ELK(datasource->filebeat->logstash->elasticsearch->kibana) 本文示例日志程序基于as ...

  4. Apache Solr Velocity模板注入rce+获取交互式shell

    前言: 官方的poc.exp payload只能获取很低的命令执行权限,甚至有些符号.命令还被过滤了,例如管道符被过滤.并且不能写入.下载文件,不能使用管道符重定向文件.那么我们只能通过获取到交互式s ...

  5. 安装JumpServer到CentOS(YUM)

    运行环境 系统版本:CentOS Linux release 7.6.1810 (Core) 软件版本:JumpServer-1.4.8 硬件要求:最低2核4GB 官方文档:https://docs. ...

  6. vim 配置 jedi-vim( ubuntu:15.10 )

    确保 vim 支持 python3 或者 python 如果你已经安装了 vim, 可以通过vim --version, 在输出中找到 +python3 或者 +python 字样的话, 就可以跳过该 ...

  7. Pikachu-目录遍历

    目录遍历漏洞概述 在web功能设计中,很多时候我们会要将需要访问的文件定义成变量,从而让前端的功能便的更加灵活. 当用户发起一个前端的请求时,便会将请求的这个文件的值(比如文件名称)传递到后台,后台再 ...

  8. 再访JavaScript对象(原型链和闭包)

    一:原型链简介 JavaScript通常被描述为基于原型的语言 (从继承机制的角度)- 为了提供继承,对象(注意:区别于实例)可以拥有一个原型对象,它充当一个模板对象,它继承了方法和属性.对象的原型对 ...

  9. tensor维度变换

    维度变换是tensorflow中的重要模块之一,前面mnist实战模块我们使用了图片数据的压平操作,它就是维度变换的应用之一. 在详解维度变换的方法之前,这里先介绍一下View(视图)的概念.所谓Vi ...

  10. 【spring boot】SpringBoot初学(5)– WebService之Jersey

    前言 github: https://github.com/vergilyn/SpringBootDemo 代码位置: 一.准备 spring boot对jersey1.x与jersey2.x的注入方 ...