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

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

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

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

然而,问题仍然存在。

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

你能给我一些建议吗?

谢谢!


当前回答

尝试使用普通的Windows shell,如CMD。

其他回答

对于那些在Jenkins管道中得到这个错误的人,可以使用SSH代理插件来修复。然后像这样包装你的git命令:

sshagent(['my-ssh-key']) {
    git remote set-url origin git@github.com:username/reponame.git
    sh 'git push origin branch_name'
}

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

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

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

[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://github.com/username/<project_name>.git

使用这种格式

git@github.username/<project_name>.git

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

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

希望这能有所帮助。

请检查以下内容

Android Studio ->首选项->版本控制-> Git ->使用凭据助手