Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错

时间:2022-01-28 11:26:34

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

Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错

问题分析

意思很明显,就是说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"

Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错

并且很明确当前用户已经是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凭据(或者在开始菜单中搜索 【凭据管理器】)

Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错

打开凭据管理器后,下拉在普通凭证,展开这条github.com相关的凭据,直接删除 或者 点编辑修改,再拉取或者提交的时候会让我们重新输入用户名密码 。
Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错

Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错
好了,问题解决,现在去各类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. 基于cookie实现zTree树刷新后,展开状态不变

    1.除了引用jQuery和zTree的JS外,引用cookie的JS: <script type="text/javascript" src="~/Scripts/ ...

  2. WPF Radio组的绑定

    都是控件编,RadioButtion 简单绑定使用,model.cs下边定义属性 private int _isSuccess; public int IsSuccess { get { return ...

  3. sublime text 3 安装中文

    本经验目前在Ubuntu14.04环境下,已有搜狗输入法 for Linux和Sublime Text 3的情况下安装成功. END 解决方法步骤2   1 保存下面的代码到文件sublime_imf ...

  4. Missing Number ——LeetCode

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

  5. centos 环境下monolog&plus;php 方案

    1.在项目中,日志系统有多重要详细所有程序员都知道,monolog就是一个最好的解决方案,有各种级别,各种日志存储方式,具体可以上monolog官方了解http://monolog.ow2.org/ ...

  6. Android 中更新UI的方法

    1)使用Activity.runOnUiThread(Runable action)方法 情景一: 在主线程中,定义方法,在方法中启动线程. public class MainActivity ext ...

  7. border-image用法详解

    图像边框 border-image使用方法:border-image:url('图像路径') 边距(不能带单位)/宽度 上下方式 左右方式:(四个边距,上右下左,相同时可缩写为一个)repeat平铺 ...

  8. &lbrack;Swift&rsqb;LeetCode1023&period; 驼峰式匹配 &vert; Camelcase Matching

    A query word matches a given pattern if we can insert lowercase letters to the pattern word so that ...

  9. CentOS 7编译OpenWRT

    安装必要的依赖 yum install subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel ...

  10. BufferReader BufferWriter

    Copying information from one file to another with 'BufferReader BufferWriter' public class Demo5 { p ...