当我试图在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时错误:致命:无法读取用户名
然而,问题仍然存在。
在添加/删除原点后,我仍然得到相同的错误。
你能给我一些建议吗?
谢谢!
当前回答
如果你想继续使用https代替ssh,出于安全考虑,不要输入你的用户名和密码。
你也可以试试Github OAuth令牌,然后你就可以了 Git配置remote.origin.url 'https://{token}@github.com/{username}/{project}.git' 或 Git远程添加原点“https://{token}@github.com/{username}/{project}.git”
这对我很管用!
其他回答
我通过清除无效缓存得到了答案,然后清洁构建帮助我。
选择“File > Invalidate Caches / Restart”,然后单击 “无效并重新启动”按钮。 选择Build > Clean Project,然后选择Build > Rebuild 项目。
这是系统凭据缓存中存储的凭据的问题。你可能有配置变量“credential”。Helper '设置为wincred或winstore,它无法清除它。如果启动控制面板并启动凭据管理器applet,那么在标记为git:https://github.com的通用凭据部分中寻找项目。如果您删除了这些,那么下次将重新创建,但是凭据帮助实用程序将要求您提供新的凭据。
如果你的回购是私人的
而不是这种格式
https://github.com/username/<project_name>.git
使用这种格式
git@github.username/<project_name>.git
您可以在SSH选项下获得正确的url
去你的Github回购->点击代码->选择SSH ->复制你的回购URL
希望这能有所帮助。
这里有一个简单的技巧
Android studio ->设置->版本控制-> git ->使用凭据助手
玩得开心
对于那些在Jenkins管道中得到这个错误的人,可以使用SSH代理插件来修复。然后像这样包装你的git命令:
sshagent(['my-ssh-key']) {
git remote set-url origin git@github.com:username/reponame.git
sh 'git push origin branch_name'
}