回答

收藏

go get results in 'terminal prompts disabled' error for github

技术问答 技术问答 314 人阅读 | 0 人回复 | 2023-09-12

我在浏览器里用 Github UI 创建私有仓库 examplesite/myprivaterepo。- ^# W5 w; i9 L! U, @" E
然后我转到了我的 go 目录(桌面)和克隆:7 a1 Z1 v7 E3 ~" I8 }+ y) G  o
    $ cd $GOPATH$ go get github.com/examplesite/myprivaterepo
    ! f% J( Y: x: K' w: o6 i; o3 Y* ?0 [5 m
到目前为止还不错。创建文件 scheduler.go,添加到 repo 并推送。0 c7 }' c' K, h$ d$ F7 _
    $ vim scheduler.go$ git add scheduler.go$ git commit$ git push
    5 J2 S  c0 h/ P7 E" o
一切正常。但是当我找到一台干净的笔记本电脑,尝试克隆 repo 有错误:
) c$ G" ]  f$ O
    # Now on laptop,which doesn't yet know about the repo$ cd $GOPATH$ go get github.com/examplesite/myprivaterepo# At this point it should ask for my user ID and password ,right? But it doesn't.# Instead,this error occurs:cd .; git clone https://github.com/examplesite/myprivaterepo /Users/tom/go/src/github.com/examplesite/myprivaterepoCloning into '/Users/tom/go/src/github.com/examplesite/myprivaterepo'...fatal: could not read Username for 'https://github.com': terminal prompts disabledpackage github.com/examplesite/myprivaterepo: exit status 128
    & ]; ^' C3 j0 i0 ^: o
为什么我的笔记本电脑讨厌我自己的回购?我怎样才能让它接受它的命运?非常感谢。
5 p0 S$ d! t% F" ?6 k                                                               
+ g$ `. Z' N- q    解决方案:                                                                : n) i4 ~0 D- s7 D
                                                                我发现这很有帮助。它解决了我的问题。此命令将允许您的 2FA 执行其操作(省去输入用户名和密码的麻烦):) u7 [4 p' |0 X+ K
    git config --global --add url."git@github.com:".insteadOf "https://github.com/"
    + A0 j6 Y( b/ \/ S+ J
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则