致命:无法读取 'https //github.com' 设备未配置的用户名

Fatal: could not read username for 'https //github.com' device not configured

我正在尝试使用 SublimeGit 插件将代码推送到 github,但我遇到了一些奇怪的事情。

Pushing to https://github.com/username/username.github.io.git

fatal: could not read Username for 'https://github.com': Device not configured

问之前搜了很多,喜欢, 。

但问题依然存在,我们将不胜感激。

git 需要询问用户名或密码时,您会收到该错误 (fatal: could not read Username for 'https://github.com': Device not configured),并且 (a) 唯一可用的机制是在控制台上询问,并且 (b)没有可用的控制台(git 没有连接到 tty 设备,即,你不是 运行 git 交互)。

这通常发生在您从某种 gui 工具调用 git 并且没有配置适当的凭证助手的环境中。

有多种方法可以解决这个问题:

  • 最简单的方法之一是使用 ssh 身份验证而不是 https

  • 您可以将 github 的凭据硬编码到本地 git 存储库中,如 gitcredentials 文档中所述。

  • 您可以配置适当的辅助应用程序。一个可能已经配置好了,但 git 可能根本找不到它。 gitcredentials 手册页也有关于此选项的信息。

@codrus 的评论帮助我解决了 sourcetree 上的问题 转到首选项 -> 选项卡 Git -> 部分 Git 版本 -> 按钮使用系统 Git,以及对话框 'git'.[=10= 中的 select ]

MacOS: Android Studio Preferences -> Git -> 在底部,使用 Credentials helper(确保已选中)

Windows: Android Studio 文件 -> 设置 -> Git -> 检查底部的 Credentials Helper