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

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

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

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

然而,问题仍然存在。

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

你能给我一些建议吗?

谢谢!


当前回答

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

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

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

其他回答

像这样替换你的远程url:

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

如果你的回购是私人的

而不是这种格式

https://github.com/username/<project_name>.git

使用这种格式

git@github.username/<project_name>.git

您可以在SSH选项下获得正确的url

去你的Github回购->点击代码->选择SSH ->复制你的回购URL

希望这能有所帮助。

我在这里找到了答案:

编辑~ /。并添加以下内容:

[url "git@github.com:"]
 insteadOf = https://github.com/

虽然它解决的问题不同,但错误代码是一样的…

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

简短的回答:

git init
git add README.md
git commit -m "first commit"


git remote add origin https://github.com/{USER_NAME}/{REPOSITORY_NAME}.git
git push --set-upstream origin master

如果不是新的存储库,请忽略前三行。

长描述:

刚刚遇到了同样的问题,因为上面的答案对我没有帮助,我决定张贴这个对我有用的解决方案。

一些笔记:

日志含义生成SSH密钥 SSH密钥已添加到GitHub,仍然有此错误。 我在GitHub上为这个项目创建了一个新的存储库,并遵循了所描述的步骤

作为命令行工具,我使用GitShell(对于Windows,我使用Terminal)。Mac上的app)。 GitShell是GitHub官方工具,可以从https://windows.github.com/下载