我有一个项目托管在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 push就遇到了这个问题,那么有一个超级简单的解决方法。
仅限Mac用户使用。您需要删除GitHub的OSX Keychain访问条目。您可以通过终端运行以下命令来完成。
通过命令行删除凭据
通过命令行,可以直接使用凭据帮助程序擦除密钥链条目。
要做到这一点,键入以下命令:
git credential-osxkeychain erase
host=github.com
protocol=https
# [Now Press Return]
如果它成功了,什么也不会打印出来。为了测试它的工作,试着从GitHub克隆一个存储库,或者像我的情况下git push一样再次运行之前的操作。如果提示输入密码,则该keychain条目已被删除。
这种情况发生的原因有很多。在我的案例中,没有一个解决方案有效。特别是,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.