回答

收藏

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

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

我在浏览器里用 Github UI 创建私有仓库 examplesite/myprivaterepo。0 f, @1 P# _' s0 q# c$ I/ Q  z
然后我转到了我的 go 目录(桌面)和克隆:
8 y4 A2 s4 a& @7 g) b
    $ cd $GOPATH$ go get github.com/examplesite/myprivaterepo
    / r' A0 M& |( R. P& h
到目前为止还不错。创建文件 scheduler.go,添加到 repo 并推送。. _# x$ ~* S+ e& A6 a; b/ Z. P
    $ vim scheduler.go$ git add scheduler.go$ git commit$ git push
    - J* E/ [( L: }6 D* ~! k
一切正常。但是当我找到一台干净的笔记本电脑,尝试克隆 repo 有错误:3 {9 w" z( B* t) J1 J4 y
    # 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
    ! W: I- I6 H3 o) t3 y/ j
为什么我的笔记本电脑讨厌我自己的回购?我怎样才能让它接受它的命运?非常感谢。
$ ~) I  \8 O1 v4 m! V( n6 Z                                                                + F1 x- K0 ~) r' U6 ~" T: c
    解决方案:                                                               
( O4 R. a4 T$ ~# D, a! U                                                                我发现这很有帮助。它解决了我的问题。此命令将允许您的 2FA 执行其操作(省去输入用户名和密码的麻烦):
/ P& R- v3 @& b# t3 T
    git config --global --add url."git@github.com:".insteadOf "https://github.com/"
    ' X! m8 m: [3 c3 _9 A3 [
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则