我有一个项目托管在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上给出的说明和许多堆栈讨论的建议,但没有办法。你知道我可能做错了什么吗?


当前回答

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

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

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

其他回答

因为你可能想让你的账户启用2FA,你可以设置一个ssh密钥,这样你就不需要每次你想把工作推送到Github时都输入你的Github凭据。

您可以在文档中找到所有的ssh设置步骤。首先,确保当前没有任何ssh密钥(id_rsa. exe)。Pub,等等)使用$ ls -al ~/.ssh

在这种情况下,如果你得到这个错误信息:

使用github创业 使用凭据。在git配置中,Helper =wincred 使用您最近更改的Windows凭据

然后看看这个答案: https://stackoverflow.com/a/39608906/521257

Windows将凭据存储在凭据管理器中,清除或更新它。

我经常遇到这个问题。 确保你设置了git——config user.name ""而不是你的真实姓名,我已经做过几次了。

这种情况发生的原因有很多。在我的案例中,没有一个解决方案有效。特别是,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.

我也有同样的问题。我通过在客户端应用程序的repo设置中将远程分支的路径从https://github.com/YourName/RepoName更改为git@github.com:YourName/RepoName.git来解决这个问题。