When you are working on GitHub, you will be adding and deleting gits, making it remote for your team to access it from anywhere. You are also allowed to share your programs with other programmers or non-programmers to take a reference or learn the concepts. Github doesn’t seem to be a complex one, but some errors can’t let you do the work, and the ‘error: fatal: could not read username for ‘https://github.com’: terminal prompts disabled’ issue is one of those.
Although the error seems frustrating, it can be solved simply. First, let’s check out how the error occurs
How the Error ‘error: fatal: could not read username for ‘https://github.com’: terminal prompts disabled’ Occurs
When you tried to create the private repository from your browser using the Github UI, you cloned the directory on the desktop. Like this:
$ cd $GOPATH
$ go get github.com/myproject/firstproject
Till here, everything seems good. Then you go ahead with the following
$ vim test_file.go
$ git add test_file.go
$ git commit
$ git push
You don’t even get any issue till here. The main error occurs when you try to use a laptop and create clone. You will get the error. Check how you get the error
$ cd $GOPATH
$ go get github.com/myproject/firstproject
# At this time, this error occurs:
cd .; git clone https://github.com/myproject/firstproject /Users/mike/Work/github.com/myproject/firstproject
Cloning into '/Users/tom/go/src/github.com/myproject/firstproject'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/myproject/firstproject: exit status 128
Now that you have found what error you get, let’s have a look at the solutions to fix it.
Solutions to Fix ‘error: fatal: could not read username for ‘https://github.com’: terminal prompts disabled’
Here, we are going to highlight the possible solution to help you fix the error
Solution – Git Configuration
The prime cause of the error warning is the git configuration. You configured the git with ‘https’, and you can solve the issue by replacing it with ‘ssh’. Either you can enable prompts or configure the git to replace https with the ssh. The process is very simple, yet really effective. Check the code
git config --global --add url."[email protected]:".insteadOf "https://github.com/"
You are also allowed to add the code at the end of ~/.gitconfig by editing it. This solution helps you get rid of the fatal terminal disabled error.
With this command, you can also easily enable 2FA, which means saving from entering username and password.
GitLab
Just like GitHub, you can also use this with Gitlab also, like this:
git config --global --add url."[email protected]:".insteadOf "https://gitlab.com/"
Conclusion
The only best solution has been discussed above to fix ‘error: fatal: could not read username for ‘https://github.com’: terminal prompts disabled’. You can just use the code to solve the error. I wish you luck!