当我试图在Windows上使用git Bash拉代码时,我有以下问题:

fatal: could not read Username for 'https://github.com': No such file or directory

我已经尝试实现这里提供的可接受的解决方案:

当推送提交Github时错误:致命:无法读取用户名

然而,问题仍然存在。

在添加/删除原点后,我仍然得到相同的错误。

你能给我一些建议吗?

谢谢!


当前回答

在我的情况下,我必须在GitHub下设置“个人访问令牌”:

设置-> developer设置 并启用SSO。

其他回答

我通过清除无效缓存得到了答案,然后清洁构建帮助我。

选择“File > Invalidate Caches / Restart”,然后单击 “无效并重新启动”按钮。 选择Build > Clean Project,然后选择Build > Rebuild 项目。

我通过安装新版本的Git解决了这个问题。我从https://git-scm.com安装的版本是2.10.2。查看最后一篇文章:https://www.bountysource.com/issues/31602800-git-fails-to-authenticate-access-to-private-repository-over-https

在更新的Git Bash中,凭证管理器窗口会弹出,您可以输入您的用户名和密码,它就可以工作了!

像这样替换你的远程url:

git remote set-url origin https://<username>@github.com/<username>/<repo>.git

我在ssh jail (jailkit)中遇到了这个问题,其中/dev/tty不存在。我用jk_cp添加了这个设备文件,错误消失了。

注意,如果你得到这个错误:

fatal: could not read Username for 'https://github.com': No error

然后,您需要将Git更新到2.16或更高版本。