当我试图在Windows上使用git Bash拉代码时,我有以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实现这里提供的可接受的解决方案:
当推送提交Github时错误:致命:无法读取用户名
然而,问题仍然存在。
在添加/删除原点后,我仍然得到相同的错误。
你能给我一些建议吗?
谢谢!
当我试图在Windows上使用git Bash拉代码时,我有以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实现这里提供的可接受的解决方案:
当推送提交Github时错误:致命:无法读取用户名
然而,问题仍然存在。
在添加/删除原点后,我仍然得到相同的错误。
你能给我一些建议吗?
谢谢!
当前回答
下面是人们得到这个错误的简单原因:您试图从一个还没有设置本地git访问的回购中拉取。对我来说,当我将公共回购更改为私有回购时,我得到了这个错误。现在我很清楚,公共回购不需要认证,但私人回购需要。
希望这有助于澄清错误发生的原因以及该原因的潜在触发因素。
其他回答
如果你的回购是私人的
而不是这种格式
https://github.com/username/<project_name>.git
使用这种格式
git@github.username/<project_name>.git
您可以在SSH选项下获得正确的url
去你的Github回购->点击代码->选择SSH ->复制你的回购URL
希望这能有所帮助。
当试图克隆无效的HTTP URL时,也会发生此错误。例如,这是我在试图克隆一个GitHub URL时得到的错误,这是几个字符:
$ git clone -v http://github.com/username/repo-name.git
Cloning into 'repo-name'...
Username for 'https://github.com':
Password for 'https://github.com':
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/username/repo-name.git/'
但是,它实际上发生在Emacs内部,所以Emacs中的错误看起来是这样的:
fatal: could not read Username for ’https://github.com’: No such device or address
因此,它没有给出一个有用的错误,告诉我那个URL上没有这样的回购,而是给了我这个错误,让我徒劳地追逐,直到我最终意识到URL是错误的。
这是git 2.7.4版本。
我在这里张贴这个,因为一个月前发生在我身上的事情,刚刚又发生了一次,让我再次陷入同样的徒劳。>:(
简短的回答:
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/下载
像这样替换你的远程url:
git remote set-url origin https://<username>@github.com/<username>/<repo>.git
如果你想继续使用https代替ssh,出于安全考虑,不要输入你的用户名和密码。
你也可以试试Github OAuth令牌,然后你就可以了 Git配置remote.origin.url 'https://{token}@github.com/{username}/{project}.git' 或 Git远程添加原点“https://{token}@github.com/{username}/{project}.git”
这对我很管用!