当我尝试在 Windows 上使用 Git Bash 拉取代码时,出现了以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实施这里提供的被接受的解决方案:
然而问题仍然存在。
在添加/删除源之后,我仍然遇到相同的错误。
能否就此问题提供建议?
谢谢!
当我尝试在 Windows 上使用 Git Bash 拉取代码时,出现了以下问题:
fatal: could not read Username for 'https://github.com': No such file or directory
我已经尝试实施这里提供的被接受的解决方案:
然而问题仍然存在。
在添加/删除源之后,我仍然遇到相同的错误。
能否就此问题提供建议?
谢谢!
我通过清除无效缓存,然后进行清洁构建来获得答案。
RUN go env -w GOPRIVATE="github.company.com"
RUN git config --global url."ssh://git@github.company.com".insteadOf "https://github.company.com"
RUN mkdir -p /root/.ssh && ssh-keyscan github.company.com >> /root/.ssh/known_hosts
RUN --mount=type=secret,id=sshKey,dst=/root/.ssh/id_rsa go mod download
go mod download
使用正确的SSH密钥。之前当我没有被授权访问仓库时,我也将SSH公钥添加到了Gitlab。在我能够访问仓库并运行go mod vendor的时候,你遇到的同样的问题也发生了。(可能是因为缓存)
go mod vendor
go: errors parsing go.mod:
/Users/macos/Documents/sample/go.mod:22: git ls-remote -q https://git.aaa.team/core/some_repo.git in /Users/macos/go/pkg/mod/cache/vcs/a94d20a18fd56245f5d0f9f1601688930cad7046e55dd453b82e959b12d78369: exit status 128:
fatal: could not read Username for 'https://git.aaa.team': terminal prompts disabled
经过一段时间的尝试,我决定删除SSH密钥和终端提示填写用户名和密码。然后一切都很好!
[url "git@git.aaa.team:"] insteadOf = https://git.aaa.team/
- Long Tran尝试使用正常的Windows shell,如CMD。
请仔细检查存储库的URL,如果存储库不存在,Github将提示您登录。
我猜这可能是为了检查您是否有权访问私有存储库。可能是为了使枚举私有存储库更加困难。但这只是猜测。/耸肩
git config --global --unset credential.helper
尝试使用SSH连接而不是HTTPS。为您的GitHub帐户设置SSH身份验证,并在部署脚本中更新存储库URL以使用SSH格式(git@github.com:/.git)。这将消除用户名和密码验证的需要。
我在ssh jail(jailkit)中遇到了这个问题,其中/dev/tty
不存在。 我使用jk_cp添加了此设备文件,错误消失了。
(base) ➜ .ssh ssh -vT git@github.com
OpenSSH_7.6p1 Ubuntu-4ubuntu0.5, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.255.112] port 81.
ssh -vT -p 22 git@github.com
可以显示连接成功。/etc/ssh/ssh_config
发现连接端口设置为81。
Host github.com
Port 22
git push
,似乎是用"ctrl+c"来停止它。git pull
和git push
git config --global user.name "Your Name Here"
- Raul Andres