git 远程匿名访问存储库被拒绝?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18664806/
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
Remote anonymous access to repository denied?
提问by raf
I'm on Ubuntu 12.04 LTS and just upgraded my git
from 1.7
-something to version 1.8.4
. The problem is when I want to push to a GitHub repository, I get the following message and the push doesn't happen:
我在 Ubuntu 12.04 LTS 上,刚刚将我git
的1.7
-something升级到 version 1.8.4
。问题是当我想推送到 GitHub 存储库时,我收到以下消息并且推送没有发生:
/caniuse $ git push
Username for 'https://github.com': rafalchmiel
Password for 'https://[email protected]':
remote: Anonymous access to rafalchmiel/caniuse.git denied.
fatal: Authentication failed for 'https://github.com/rafalchmiel/caniuse.git/'
This is what I get from git config --list
:
这是我得到的git config --list
:
user.name=Rafal Chmiel
[email protected]
alias.undo-commit=reset --soft HEAD^
color.ui=true
push.default=matching
credential.helper=cache --timeout=86400
github.user=rafalchmiel
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/rafalchmiel/caniuse.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
And these are my remotes (git remote -v
):
这些是我的遥控器 ( git remote -v
):
origin https://github.com/rafalchmiel/caniuse.git (fetch)
origin https://github.com/rafalchmiel/caniuse.git (push)
I tried setting up the SSH keys again (although this is done through HTTP) and have search for options. No luck. Any ideas on what else I could do?
我再次尝试设置 SSH 密钥(尽管这是通过 HTTP 完成的)并搜索了选项。没运气。关于我还能做什么的任何想法?
采纳答案by raf
The issues was not resolved however in the end I decided to go with SSH instead of HTTPS. SSH caused noproblems at all (and there's no need to type in the username and pass)!
问题没有解决,但最终我决定使用 SSH 而不是 HTTPS。SSH完全没有问题(而且不需要输入用户名并通过)!
回答by xtopolis
I had this issue due to the fact that I had 2-Factor-Auth enabled, and the password it was asking for was the generated password / personal access token, not my LDAP password. I didn't remember that I had set it up at the time.
我遇到了这个问题,因为我启用了 2-Factor-Auth,它要求的密码是生成的密码/个人访问令牌,而不是我的 LDAP 密码。我不记得我当时设置了它。
Creating a Personal Access Token: https://help.github.com/articles/creating-an-access-token-for-command-line-use/, allowed me to push successfully using the generated token as a password.
创建个人访问令牌:https: //help.github.com/articles/creating-an-access-token-for-command-line-use/,允许我使用生成的令牌作为密码成功推送。
Context: Internally hosted Enterprise Github. Able to clone, enabled as a collaborator, but unable to push origin master.
上下文:内部托管的 Enterprise Github。能够克隆,作为协作者启用,但无法推送源主。
回答by Alex
I had the same problem as you. But A little different with you.
我和你有同样的问题。但和你有点不同。
Username for 'https://www.github.com': [email protected]
Password for 'https://[email protected]@www.github.com':
remote: Anonymous access to xxxxx.git denied.
fatal: Authentication failed for 'https://www.github.com/yyyy/xxx
And I found the cause of problem is that I clone with the prefix of wwwhttps://www.github.com/yyyy/xxx
我发现问题的原因是我用www的前缀克隆https://www.github.com/yyyy/xxx
I solved it by git clone the repository again like this https://github.com/yyyy/xxx
, and everything go right.
我通过 git clone 存储库再次解决了这个问题https://github.com/yyyy/xxx
,一切顺利。
回答by Charles Addis
If you want to use your SSH key, you must use the following format:
如果要使用 SSH 密钥,则必须使用以下格式:
$ <snip> on MBP-0x00A3 in ~/misc/vim_dotfiles
? (git) working on branch alternate ?
?? git remote -v
origin https://github.com/<snip>/vim_dotfiles.git (fetch)
origin https://github.com/<snip>/vim_dotfiles.git (push)
$ <snip> on MBP-0x00A3 in ~/misc/vim_dotfiles
? (git) working on branch alternate ?
?? git remote add personal [email protected]:<snip>/vim_dotfiles.git
$ <snip> on MBP-0x00A3 in ~/misc/vim_dotfiles
? (git) working on branch alternate ?
?? git remote -v
origin https://github.com/<snip>/vim_dotfiles.git (fetch)
origin https://github.com/<snip>/vim_dotfiles.git (push)
personal [email protected]:<snip>/vim_dotfiles.git (fetch)
personal [email protected]:<snip>/vim_dotfiles.git (push)
Now you can do:
现在你可以这样做:
user@host:~$ git push personal <branch>
and it will force use of your SSH key.
它会强制使用您的 SSH 密钥。
回答by Rocode
I faced a similar problem and got to this question in the search for an answer.
我遇到了类似的问题,并在寻找答案时遇到了这个问题。
Figured out the issue.
想通了这个问题。
- Using the command
git push
without adding any files can give this error - Using the command
git push
without adding any commits can do the same
- 在
git push
不添加任何文件的情况下使用该命令可能会出现此错误 - 使用该命令
git push
而不添加任何提交也可以执行相同的操作
so the simple solution would be to follow this
所以简单的解决方案是遵循这个
git add --all .
git commit
git push