当我尝试将代码推送到github时,--global@github.com出现了

时间:2018-12-09 09:15:37

标签: git github

我找不到答案,也许我只是盲目地错过了一步,但是每当我尝试将代码推送到github并使用git push -u origin master时,都会提示输入密码“- global@github.com”:

我输入我的帐户密码,密码为

Password for 'https://--global@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 
'https://github.com/richardquirarte/QRealty.git/'

我已经使用过git config --global user.email并验证了那是我的电子邮件,但是它一直在提醒您。

再次,很抱歉,如果这是一个简单的解决方法,那么我只是在任何地方都找不到答案。谢谢。

4 个答案:

答案 0 :(得分:3)

您可能有一些错误的配置。

首先尝试重置远程URL和用户名:

git config --global user.name "some user name"
git remote set-url origin https://github.com/richardquirarte/QRealty.git

答案 1 :(得分:1)

好像是git config --global出了错。

尝试git config -l | grep global,看看是否有带有“ global”的配置。

如果没有,请检查您的git config credential.helper并查看是否必须删除与GitHub URL相关联的用户--global(请参阅“ problem while I was pushing my code to github.com”)。

答案 2 :(得分:0)

这是一个较晚的答案,但我遇到了同样的问题并已解决。 我不小心以某种方式将凭据用户名设置为--global,因此当系统提示我登录时,系统提示我登录--global@github.com。

要解决此问题:

git config --global credential.username "your github username here"

要确保凭据用户名正确:

git config -l

现在输入您的代码。

git push 

答案 3 :(得分:-1)

您正在使用https,它需要密码才能与服务器进行任何交互。
解决这个问题并不难,但是我建议您切换到ssh,并且您将不再需要使用密码。

阅读有关其操作方法的文档。
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

简而言之:

  • 生成ssh密钥 打开git bash并输入:ssh-keygen
  • 一旦创建了ket,就将其复制(将在您的终端上打印出公开路径)
  • 将密钥添加到您的GitHub帐户
  • 将回购URL更新为您的新URL

    git remote set-url origin <ssh url>