debuggogitCritical
go get results in 'terminal prompts disabled' error for GitHub private repo
Viewed 0 times
privateerrorpromptsgithubdisabledforrepoterminalresultsget
Problem
I created the private repo examplesite/myprivaterepo using the GitHub UI from my browser.
Then I went to my go directory (on the desktop) and cloned it:
So far so good. Created the file
Everythng's OK. But when I went to a clean laptop and tried to clone the repo, I got an error:
Why is my laptop hating on my own repo and how can I get it to accept its fate?
Thanks.
Then I went to my go directory (on the desktop) and cloned it:
$ cd $GOPATH
$ go get github.com/examplesite/myprivaterepoSo far so good. Created the file
scheduler.go, added to repo and pushed.$ vim scheduler.go
$ git add scheduler.go
$ git commit
$ git pushEverythng's OK. But when I went to a clean laptop and tried to clone the repo, I got an error:
# 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/myprivaterepo
Cloning into '/Users/tom/go/src/github.com/examplesite/myprivaterepo'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/examplesite/myprivaterepo: exit status 128Why is my laptop hating on my own repo and how can I get it to accept its fate?
Thanks.
Solution
It complains because it needs to use
or if you already use
Note: This covers all SVC, source version control, that depends on what you exactly use, github, gitlab, bitbucket)
-
If you want to keep password pompts disabled, you need to cache password. For more information on how to cache your github password on mac, windows or linux, please visit this page.
-
For more information on how to add ssh to your github account, please visit this page.
Also, more importantly, if this is a private repository for a company or for your self, you may need to skip using proxy or checksum database for such repos to avoid exposing them publicly.
To do this, you need to set
The variable is a comma-separated list of patterns (same syntax of Go's
Or
One last thing not to forget to mention, you can still configure
Please feel free to leave a comment in case you want more support or help.
ssh instead of https but your git is still configured with https. so basically as others mentioned previously you need to either enable prompts or to configure git to use ssh instead of https. a simple way to do this by running the following:git config --global --add url."git@github.com:".insteadOf "https://github.com/"or if you already use
ssh with git in your machine, you can safely edit ~/.gitconfig and add the following line at the very bottomNote: This covers all SVC, source version control, that depends on what you exactly use, github, gitlab, bitbucket)
# Enforce SSH
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
insteadOf = https://gitlab.com/
[url "ssh://git@bitbucket.org/"]
insteadOf = https://bitbucket.org/-
If you want to keep password pompts disabled, you need to cache password. For more information on how to cache your github password on mac, windows or linux, please visit this page.
-
For more information on how to add ssh to your github account, please visit this page.
Also, more importantly, if this is a private repository for a company or for your self, you may need to skip using proxy or checksum database for such repos to avoid exposing them publicly.
To do this, you need to set
GOPRIVATE environment variable that controls which modules the go command considers to be private (not available publicly) and should therefore NOT use the proxy or checksum database.The variable is a comma-separated list of patterns (same syntax of Go's
path.Match) of module path prefixes. For example,export GOPRIVATE=*.corp.example.com,github.com/mycompany/*Or
go env -w GOPRIVATE=github.com/mycompany/*- For more information on how to solve private packages/modules checksum validation issues, please read this article.
- For more information about go 13 modules and new enhancements, please check out Go 1.13 Modules Release notes.
One last thing not to forget to mention, you can still configure
go get to authenticate and fetch over https, all you need to do is to add the following line to $HOME/.netrcmachine github.com login USERNAME password APIKEY- For GitHub accounts, the password can be a personal access tokens.
- For more information on how to do this, please check Go FAQ page.
Please feel free to leave a comment in case you want more support or help.
Code Snippets
git config --global --add url."git@github.com:".insteadOf "https://github.com/"# Enforce SSH
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
insteadOf = https://gitlab.com/
[url "ssh://git@bitbucket.org/"]
insteadOf = https://bitbucket.org/export GOPRIVATE=*.corp.example.com,github.com/mycompany/*go env -w GOPRIVATE=github.com/mycompany/*machine github.com login USERNAME password APIKEYContext
Stack Overflow Q#32232655, score: 217
Revisions (0)
No revisions yet.