当我试图在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://git-scm.com安装的版本是2.10.2。查看最后一篇文章:https://www.bountysource.com/issues/31602800-git-fails-to-authenticate-access-to-private-repository-over-https
在更新的Git Bash中,凭证管理器窗口会弹出,您可以输入您的用户名和密码,它就可以工作了!
其他回答
我通过安装新版本的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中,凭证管理器窗口会弹出,您可以输入您的用户名和密码,它就可以工作了!
如果你的回购是私人的
而不是这种格式
https://github.com/username/<project_name>.git
使用这种格式
git@github.username/<project_name>.git
您可以在SSH选项下获得正确的url
去你的Github回购->点击代码->选择SSH ->复制你的回购URL
希望这能有所帮助。
按照步骤在这里设置SSH密钥:https://help.github.com/articles/generating-ssh-keys
OR
git remote add origin https://{username}:{password}@github.com/{username}/project.git
更新:如果你得到"fatal: remote origin already exists.",那么你必须使用set-url:
git remote set-url origin https://{username}:{password}@github.com/{username}/project.git
尝试使用普通的Windows shell,如CMD。
我正在使用GitHub操作,其中作业被配置为完成任务。该解决方案适用于所有git命令执行环境发生变化的ci (Jenkins、Travis、Circle)。
job1: 使用github actions actions/checkout@v2使用个人访问令牌(PAT)检出存储库,作业成功完成,存储库克隆。
job2: 使用命令git Fetch——tags获取标签。由于同样的错误,作业失败
致命:无法读取用户名https://github.com':没有这样的文件或目录
失败原因:当作业发生变化时,命令运行环境也发生了变化,即使存储库存在,但需要提供github凭据来获取标记。
解决方案:在获取作业b2中的标记之前添加此命令
Git配置remote.origin.url 'https://${{your_personal_access_token}}@github.com/${{github。库}}’
注意:${{expression}}是github actions yaml syntex,用于发现环境变量/运行表达式。