我有一个项目托管在GitHub上。我失败时,试图推动我的修改在主人。我总是得到以下错误消息

Password for 'https://git@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://git@github.com/eurydyce/MDANSE.git/'

但是,设置我的ssh密钥到github似乎没问题。实际上,当我执行ssh -T git@github.com时,我得到

Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.

这似乎表明,一切都是OK从这一边(eurydyce是我的github用户名)。我严格按照github上给出的说明和许多堆栈讨论的建议,但没有办法。你知道我可能做错了什么吗?


当前回答

这种情况发生的原因有很多。在我的案例中,没有一个解决方案有效。特别是,git拉origin master没有问我我的用户名和密码。

我在Windows上的github密码最近改了。我使用凭据管理器来管理我的密码。以下是对我有效的方法:

Confirm you are using the credential manager for git: git config --list … credential.helper=manager Run a new command prompt as administrator List all stored credential with cmdkey /list from C:\WINDOWS\system32> Remove the github target with cmdkey /delete:<target name>. In my case, the target name was github.<companyname>.com Open a new prompt and run a git command. You should get a popup asking for your usernmame and password. After providing the new credentials, it won't ask you for it again.

其他回答

运行下面的命令,然后在每一次推拉之后,它会要求你输入用户名和密码。

  git config credential.helper ""

现在当你拉/推你将被要求git凭证。不管你是通过命令提示符还是Intellij Git运行。

我通过安装GitHub CLI并运行gh auth登录来解决我的问题

看到的: https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git#github-cli

您可能会得到这个错误,因为您已经更新了密码。所以在终端上,首先确保你从钥匙链中清除你的GitHub凭证,然后将你的更改推到你的回购,终端将要求你的用户名和密码。

不需要依赖于生成个人访问令牌,然后尝试使用个人访问令牌在您的密码的地方。

快速修复方法是将远程URL设置为指向ssh而不是https。

这个git远程设置url来源git@github.com:用户名/存储库

我也有同样的问题

$ git clone https://github.com/sample-url.git
Cloning into 'Project'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/sample-url.git/'

我只是git init,然后git clone <clone-url>

git init
git clone https://github.com/your-clone-Url

这对我很管用。