git Github Push 上的权限被拒绝错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17857283/
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
Permission denied error on Github Push
提问by Irfan
Recently, I'm added as a member/contributor for Github project. I have cloned that project on local machine.
最近,我被添加为 Github 项目的成员/贡献者。我已经在本地机器上克隆了那个项目。
I have made some changes and committed locally and now trying to Push changes to original repo but when I try to Push,I get some permission error?
我做了一些更改并在本地提交,现在尝试将更改推送到原始存储库,但是当我尝试推送时,出现了一些权限错误?
C:\Users\MM\Documents\GitHub\software-licensing-php [master]> git push
origin master
remote: Permission to EasySoftwareLicensing/software-licensing-php.git denied to
irfandayan.
fatal: unable to access 'https://github.com/EasySoftwareLicensing/software-licen
sing-php.git/': The requested URL returned error: 403
C:\Users\MM\Documents\GitHub\software-licensing-php [master]> git statu
s
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
Am I lacking some permission for pushing changes so I could ask the original author of project?
我是否缺乏推送更改的权限,以便我可以询问项目的原始作者?
回答by cnd
- click fork button on original github project page
- clone your forked repository instead original
- push to it
- press Pull Requests button on your repository
- create it
- wait for original author to accept it
- 单击原始 github 项目页面上的 fork 按钮
- 克隆您的分叉存储库而不是原始存储库
- 推到它
- 在您的存储库上按下 Pull Requests 按钮
- 创造它
- 等待原作者接受
回答by Luan Si Ho
I used to have the same error when i change my user email by git config --global user.emailand found my solution here: Go to: Control Panel -> User Accounts -> Manage your credentials -> Windows Credentials
当我通过git config --global user.email更改我的用户电子邮件 并在此处找到我的解决方案时,我曾经遇到过同样的错误 : 转到:控制面板 -> 用户帐户 -> 管理您的凭据 -> Windows 凭据
Under Generic Credentialsthere are some credentials related to Github, Click on them and click "Remove".
在通用凭据下有一些与 Github 相关的凭据,单击它们并单击“删除”。
and when you try to push something, you need to login again. hope this will be helpful for you
当您尝试推送某些内容时,您需要再次登录。希望这对你有帮助
回答by Srinivas Narula
In could able to resolve this issue with giving username and password in below url.
In 可以通过在下面的 url 中提供用户名和密码来解决这个问题。
Please replace username and password with your Github credentials:
请将用户名和密码替换为您的 Github 凭据:
git remote set-url origin https://<username>:<password>@github.com/<username>/FirstRepository.git
回答by mlunoe
For some reason my push and pull origin was changed to HTTPS-urlin stead of SSH-url(probably a copy-paste error on my end), but trying to push would give me the following error after trying to login:
出于某种原因,我的推送和拉取源被更改为HTTPS-url而不是SSH-url(可能是我的复制粘贴错误),但尝试推送会在尝试登录后给我以下错误:
Username for 'https://github.com': xxx
Password for 'https://[email protected]':
remote: Invalid username or password.
Updating the remote origin with the SSH url, solved the problem:
使用SSH url更新远程源,解决了问题:
git remote set-url origin [email protected]:<username>/<repo>.git
Hope this helps!
希望这可以帮助!
回答by Shahbaz
See the github help on cloning URL. With HTTPS, if you are not authorized to push, you would basically have a read-only access. So yes, you need to ask the author to give you permission.
请参阅有关克隆 URL的github 帮助。使用 HTTPS,如果您无权推送,您基本上将拥有只读访问权限。所以是的,你需要征求作者的许可。
If the author doesn't give you permission, you can always fork (clone) his repository and work on your own. Once you made a nice and tested feature, you can then send a pull request to the original author.
如果作者没有给你许可,你总是可以分叉(克隆)他的存储库并自己工作。一旦你制作了一个很好的和经过测试的功能,你就可以向原作者发送拉取请求。
回答by not2qubit
Another way to get this error, is if you have duplicate or conflicting ~/.ssh/*
entries. First check what is on your ssh key-chain with:
获得此错误的另一种方法是,如果您有重复或冲突的~/.ssh/*
条目。首先检查您的 ssh 钥匙串上的内容:
$ ssh-add -l
2048 SHA256:<hash1> [email protected] (RSA)
2048 SHA256:<hash2> [email protected] (RSA)
2048 SHA256:<hash3> [email protected] (RSA)
As you can see there are two emails which are the same, and easy for you to get confused. Then check your config
file:
如您所见,有两封相同的电子邮件,很容易让您感到困惑。然后检查您的config
文件:
$ cat ~/.ssh/config
# GitHub: [email protected]
Host github_ex
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_ex
# GitHub: [email protected]
Host github
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github
# Bitbucket: [email protected]
Host bitbucket
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/bitbuc
Here you see that you have two different email accounts to github but same HostName
. Someone is bound to get confused, including your git.
在这里你看到你有两个不同的 github 电子邮件帐户,但相同的HostName
. 肯定有人会感到困惑,包括你的 git。
To resolve, manually remove (after copying) the (default) files:
要解决,请手动删除(复制后)(默认)文件:
cd ~/.ssh
rm id_rsa
rm id_rsa.pub
Now copy back the one you want to use, for example Host github
:
现在复制回您要使用的那个,例如Host github
:
cp -a github id_rsa
cp -a github.pub id_rsa.pub
Then try again.
然后再试一次。
For some reason, removing keys with ssh-add -d id_rsa
didn't work as expected, as it seem that key-chain is cached.
出于某种原因,删除密钥ssh-add -d id_rsa
并没有按预期工作,因为钥匙链似乎已被缓存。
回答by not2qubit
Based on the information that the original poster has provided so far, it might be the case that the project owners of EasySoftwareLicensing/software-licensing-phpwill only accept pull requests from forks, so you may need to fork the main repo and push to your fork, then make pull requests from it to the main repo.
根据原发帖者目前提供的信息,EasySoftwareLicensing/software-licensing-php 的项目负责人可能只接受来自分叉的拉取请求,因此您可能需要分叉主 repo 并推送到你的 fork,然后从它向主 repo 发出拉取请求。
See the following GitHub help articlesfor instructions:
有关说明,请参阅以下GitHub 帮助文章: