git GITHUB 推送失败:失败,错误:致命:无法访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38939112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:11:54  来源:igfitidea点击:

GITHUB Push failed: Failed with error: fatal: unable to access

androidgit

提问by cheng

Before, i user A account to push code on Android Studio.Now i logout and change into B account to Push. When pushing error occur:

之前,我使用 A 帐户在 Android Studio 上推送代码。现在我注销并更改为 B 帐户推送。出现推送错误时:

Push failed: Failed with error: fatal: unable to access 'https://github.com/thangcoder/demo.git/': The requested URL returned error: 403

And below error when i push in command:

当我输入命令时出现以下错误:

$ git push -u origin master
remote: Permission to thangcoder/demo.git denied to trangchongcheng.
fatal: unable to access 'https://github.com/thangcoder/demo.git/': The requested URL returned error: 403

(trangchongcheng is A Account)

(trangchongcheng是A账户)

Please for me sugest, thank all.

请为我建议,谢谢大家。

回答by 96var3

I got the same error. Here's how you fix it.

我得到了同样的错误。这是您修复它的方法。

The problem was that your git repository was secured with SSH keys.

问题是您的 git 存储库使用 SSH 密钥进行保护。

Login to GitHub> Your repository for the project> Settings tab> Deploy keys

登录GitHub>您的项目存储库>设置选项卡>部署密钥

Delete the key/keys assigned for your Desktop.

删除为您的桌面分配的键。

And try pushing the repository from Android Studio again.

并再次尝试从 Android Studio 推送存储库。

For pushing a repository refer: "How to use GitHub with Android Studio".

如需推送存储库,请参阅:“如何将 GitHub 与 Android Studio 结合使用”

This worked for me!

这对我有用!

回答by u9751509

change your file .git/config

更改您的文件 .git/config

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://你的github用户名:你的github密码@github.com/Pandaring/Demos.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

回答by ershad linux

i had this problem, please do this way:

我遇到了这个问题,请这样做:

1.git config --global --unset user.name
2.git config --global --unset user.email
3.git remote add origin https://github.com/username/file.git
4.git push -u origin master

after push github asks you username and password from user B

在推送 github 向用户 B 询问您的用户名和密码后

回答by puraky

I just had the same problem, finding a solution was time consuming. Actually reading the error is helpfull:

我刚刚遇到了同样的问题,找到解决方案很耗时。实际上阅读错误是有帮助的:

Push failed: Failed with error: fatal: unable to access

推送失败:失败,错误:致命: 无法访问

well, thats the point. just add the user as an collaborator to the repository.

嗯,这就是重点。只需将用户作为协作者添加到存储库。

https://help.github.com/articles/inviting-collaborators-to-a-personal-repository/

https://help.github.com/articles/inviting-collaborators-to-a-personal-repository/

Note: adding the user to the organization is not enough.

注意:将用户添加到组织是不够的。

回答by Ramit

It's clear you do not have write permission on repo. Please ask thangcoder to add write permission to you.

很明显你没有 repo 的写权限。请要求thangcoder 为您添加写入权限。

回答by theQuestionMan

Check that your computer has permission to push to that repository.

检查您的计算机是否有权推送到该存储库。

Here's how you can check:

您可以通过以下方式进行检查:

Login to your github account and direct yourself to this link: https://github.com/settings/keys

登录您的 github 帐户并直接访问此链接:https: //github.com/settings/keys

Now do you see your machine listed on that link? If not add a key to enable your machine to push to a remote repository.

现在你看到你的机器列在那个链接上了吗?如果没有,请添加一个密钥以使您的机器能够推送到远程存储库。

Here's how you can add a key:

添加密钥的方法如下:

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/