已解决 - git push 出错,fatal: Authentication failed

问题:

    执行 git push时报错,fatal: Authentication failed

remote: Anonymous access to XXX/xxx.git denied.
fatal: Authentication failed for 'https://www.github.com/XXX/xxx.git/'

    请注意报错信息,本文针对由于远程仓库地址写错(多写了个www)而导致 git push 出错的情况。

解决方法:

    执行如下命令修改 remote.origin.url。

git remote remove origin 
git remote add origin https://github.com/XXX/xxx.git
git push

 

解决过程:

    试过重置 user.name 和 user.email ,还是报错。下面记录一下我的解决过程:

    git config --list 当前的配置是否正确,包括 user.name,user.email,remote 。

user.email=email@yeah.net
user.name=XXX
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://www.github.com/XXX/xxx.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

    不知道你注意没,上述报错提示中远程库的地址是https://www.github.com....,而不是https://github.com...。所以修改 remote.origin.url。

#git remote 相关命令
git remote set-branches [--add] <name> <branch>...
git remote set-url [--push] <name> <newurl> [<oldurl>]
git remote set-url --add <name> <newurl>
git remote set-url --delete <name> <url>

    通过上诉命令先删除再添加,把 remote.origin.url 的值改为 https://github.com/XXX/xxx.git,然后 git push 就可以了。

    不知道为什么,我删除不了remote.origin.url ,所以我运行了如下命令。

git remote remove origin 
git remote add origin https://github.com/XXX/xxx.git
git push

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值