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

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

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

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

然而,问题仍然存在。

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

你能给我一些建议吗?

谢谢!


当前回答

[SSH] executing...
fatal: could not read Username for 'https://github.com': No such device or address

[SSH] completed
[SSH] exit-status: 1

Build step 'Execute shell script on remote host using ssh' marked build as failure
Finished: FAILURE

索尔:- 如果存储库是私有的,它也属于另一个人或组织,并且你是该存储库的贡献者,那么你可以从Jenkins作业中运行git命令,它不会提示你输入用户名和密码。

https://username:token@github.com/accountname/reponame.git

其他回答

我也面临着同样的问题。当我使用HTTPS URL克隆一个repo,然后尝试推送更改(在Linux/Mac上使用Shell或在Windows上使用Git Bash)时,出现了这个问题:

git clone https://github.com/{username}/{repo}.git

但是,当我使用SSH URL克隆时,这个问题没有发生:

git clone git@github.com:{username}/{repo}.git

如果你已经使用HTTPS克隆了repo,并且不想重做所有事情,你可以使用set-url将原始URL更改为SSH URL:

git remote set-url origin git@github.com:{username}/{repo}.git

注意:我有SSH密钥添加到我的GitHub帐户。如果没有设置SSH密钥,这种方法也不能工作。

像这样替换你的远程url:

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

这是系统凭据缓存中存储的凭据的问题。你可能有配置变量“credential”。Helper '设置为wincred或winstore,它无法清除它。如果启动控制面板并启动凭据管理器applet,那么在标记为git:https://github.com的通用凭据部分中寻找项目。如果您删除了这些,那么下次将重新创建,但是凭据帮助实用程序将要求您提供新的凭据。

我通过安装新版本的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中,凭证管理器窗口会弹出,您可以输入您的用户名和密码,它就可以工作了!

我通过清除无效缓存得到了答案,然后清洁构建帮助我。

选择“File > Invalidate Caches / Restart”,然后单击 “无效并重新启动”按钮。 选择Build > Clean Project,然后选择Build > Rebuild 项目。