简体   繁体   English

无法推送git:权限被拒绝

[英]Not able to push on git : Permission denied

Initially my git was logged in to abc@gmail.com Later I want to push my new code to repository to email xyz@gmail.com 最初,我的git登录到abc@gmail.com,后来我想将新代码推送到存储库中,以电子邮件发送xyz@gmail.com

Trying to push my android code on github. 尝试在github上推送我的android代码。

All the steps are going fine. 所有步骤都进行顺利。 Now when last when I do this : 现在,当我这样做时:

git push origin master

It shows : 表明 :

remote: Permission to ****/******.git denied to xyz@gmail.com.
fatal: unable to access 'https://github.com/*********/ScanFiles.git/': The requested URL returned error: 403

But when I do : git config --global user.email It shows xyc@gmail.com . 但是当我这样做时: git config --global user.email它显示xyc@gmail.com

What is the problem? 问题是什么?

Git doesn't care what you put in the user name and email address fields. Git不在乎您在用户名和电子邮件地址字段中输入的内容。 You can call yourself whatever you like. 您可以随便叫什么。 When you run git push , though, you have your Git call up some other Git on some other computer or web site—some other machine, anyway, and that other machine requires that you authenticate yourself to that machine before that machine will run its Git. 但是,当您运行git push时,您的Git会在其他计算机或网站上(无论如何是其他计算机)调用其他Git,并且该其他计算机要求您对该计算机进行身份验证然后该计算机才能运行 Git。 。

It's this step—the authentication of yourself as yourself—that is failing. 正是这一步(对自己的身份进行身份验证)失败了。 Git is not yet involved! Git尚未参与! Once you solve that problem, then you can worry about whether the Git on that system believes you when you claim to be Barack Obama or whoever; 一旦你解决这个问题, 那么你可以不用担心,当你声称自己是奥巴马或任何人在该系统上的Git是否相信你; that's a separate issue. 那是一个单独的问题。

Since you are using GitHub, you may wish to start with GitHub's help page on authentication . 由于您使用的是GitHub,因此您不妨从GitHub的身份验证帮助页面开始 You might also read this answer on credential helpers and Why does GitHub recommend HTTPS over SSH? 您可能还会在凭证帮助程序上阅读此答案为什么GitHub为什么建议在SSH上使用HTTPS? (which notes that GitHub themselves have waffled over whether to prefer ssh or https). (这说明GitHub本身在选择ssh还是https上感到困惑)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM