对存储库的远程匿名访问被拒绝了?

时间:2013-09-06 19:04:17

标签: git github

我使用的是Ubuntu 12.04 LTS,只是将git1.7升级为版本1.8.4。问题是,当我想要推送到GitHub存储库时,我得到以下消息并且不会发生推送:

/caniuse $ git push
Username for 'https://github.com': rafalchmiel
Password for 'https://rafalchmiel@github.com': 
remote: Anonymous access to rafalchmiel/caniuse.git denied.
fatal: Authentication failed for 'https://github.com/rafalchmiel/caniuse.git/'

这是我从git config --list得到的:

user.name=Rafal Chmiel
user.email=rafalmarekchmiel@gmail.com
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/*

这些是我的遥控器(git remote -v):

origin  https://github.com/rafalchmiel/caniuse.git (fetch)
origin  https://github.com/rafalchmiel/caniuse.git (push)

我尝试再次设置SSH密钥(虽然这是通过HTTP完成的)并且已经搜索了选项。没运气。关于我还能做些什么的任何想法?

5 个答案:

答案 0 :(得分:7)

问题没有解决,但最终我决定使用SSH而不是HTTPS。 SSH导致 no 问题(并且无需输入用户名并通过)!

答案 1 :(得分:2)

我遇到了这个问题,因为我启用了2-Factor-Auth,而它要求的密码是生成的密码/个人访问令牌,而不是我的LDAP密码。我不记得我当时设置了它。

创建个人访问令牌:https://help.github.com/articles/creating-an-access-token-for-command-line-use/,允许我使用生成的令牌作为密码成功推送。

上下文:内部托管的企业Github。能够克隆,作为协作者启用,但无法推送原始主。

答案 2 :(得分:1)

我和你有同样的问题。但与你有点不同。

Username for 'https://www.github.com': xxxx@gmail.com
Password for 'https://xxxx@gmail.com@www.github.com':
remote: Anonymous access to xxxxx.git denied.
fatal: Authentication failed for 'https://www.github.com/yyyy/xxx

我发现问题的原因是我使用前缀 www https://www.github.com/yyyy/xxx

进行克隆

我通过git克隆存储库再次解决了这个问题https://github.com/yyyy/xxx,一切顺利。

答案 3 :(得分:0)

我遇到了类似的问题,并在寻找答案时得到了这个问题。

找出问题。

  1. 使用命令git push而不添加任何文件可能会出现此错误
  2. 使用命令git push而不添加任何提交可以执行相同的操作
  3. 所以简单的解决方案就是遵循这个

    git add --all .
    git commit
    git push
    

答案 4 :(得分:0)

如果要使用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 git@github.com:<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    git@github.com:<snip>/vim_dotfiles.git (fetch)
personal    git@github.com:<snip>/vim_dotfiles.git (push)

现在你可以做到:

user@host:~$ git push personal <branch>

它将强制使用您的SSH密钥。