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

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

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

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

然而,问题仍然存在。

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

你能给我一些建议吗?

谢谢!


当前回答

这里什么都试过了,都没用。

然而,当我试图通过gitconfig——system——list进行调试时,我得到了致命的结果:无法读取配置文件'/etc/gitconfig':没有这样的文件或目录。

所以我做了以下的事情,

sudo ln -s $HOME/.gitconfig /etc/gitconfig

瞧,它起作用了。

其他回答

像这样替换你的远程url:

git remote set-url origin https://<username>@github.com/<username>/<repo>.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'
}

这里什么都试过了,都没用。

然而,当我试图通过gitconfig——system——list进行调试时,我得到了致命的结果:无法读取配置文件'/etc/gitconfig':没有这样的文件或目录。

所以我做了以下的事情,

sudo ln -s $HOME/.gitconfig /etc/gitconfig

瞧,它起作用了。

我在ssh jail (jailkit)中遇到了这个问题,其中/dev/tty不存在。我用jk_cp添加了这个设备文件,错误消失了。

从Android Studio终端执行git拉取 例如:test@test:~/StudioProjects/dummy-project-android$ git 添加用户名 例如:test@test:~/StudioProjects/dummy-project-android$ "username" 添加用户密码 “https://dummy-project-android@git.com”的密码:“Password”

之后,我们就可以进行剩下的手术了