. Advertisement .
..3..
. Advertisement .
..4..
I get the error message:
# 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 128
Has anyone ever faced this problem? How to troubleshoot the “ fatal: could not read username for ‘https://github.com’: terminal p rompts disabled”. But the problem is appearing when I try to operate the following program
$ cd $GOPATH
$ go get github.com/examplesite/myprivaterepo
$ vim scheduler.go
$ git add scheduler.go
$ git commit
$ git push
The cause: This error happens because your git is still configured with https but it has to use
ssh
instead of usinghttps
Solution: To solve this problem, you need to enable prompts or configure git to use ssh instead of using https. It is very easy by doing the following:
If in your machine you have already used
ssh
withgit
, you also can edit~/.gitconfig
and add the following line at the bottom.This was extremely helpful and solved my problem. This command will enable your 2FA (and save you from entering your username/password) to do its job.
Github:
Gitlab:
Source: http://albertech.blogspot.com/2016/11/fix-git-error-could-not-read-username.html
You can still use SSH if you don’t have 2FA.
The
.gitconfig
result will look like this: