I have the following problem when I try to pull code using git Bash on Windows:
fatal: could not read Username for \'https://github.com\': No such file or dir
This error can also happen when trying to clone an invalid HTTP URL. For example, this is the error I got when trying to clone a GitHub URL that was a few characters off:
$ git clone -v http://github.com/username/repo-name.git
Cloning into 'repo-name'...
Username for 'https://github.com':
Password for 'https://github.com':
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/username/repo-name.git/'
It actually happened inside Emacs, though, so the error in Emacs looked like this:
fatal: could not read Username for ’https://github.com’: No such device or address
So instead of a helpful error saying that there was no such repo at that URL, it gave me that, sending me on a wild goose chase until I finally realized that the URL was incorrect.
This is with git version 2.7.4.
I'm posting this here because it happened to me a month ago and again just now, sending me on the same wild goose chase again. >:(
If you want to continue use https instead ssh, and avoid type into your username and password for security reason.
You can also try Github OAuth token, then you can do
git config remote.origin.url 'https://{token}@github.com/{username}/{project}.git'
or
git remote add origin 'https://{token}@github.com/{username}/{project}.git'
This works for me!
Short Answer:
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/{USER_NAME}/{REPOSITORY_NAME}.git
git push --set-upstream origin master
Ignore first three lines if it's not a new repository.
Longer description:
Just had the same problem, as non of the above answers helped me, I have decided to post this solution that worked for me.
Few Notes:
As the command line tool I used GitShell (for Windows, I use Terminal.app on Mac).
GitShell is official GitHub tool, can be downloaded from https://windows.github.com/
Hope this helps to anyone who has the same problem.
trying the CreativeMagic solution, the credential problem is confirmed:
prompt>>>Username for 'https://github.com'
So, I changed my origin url with
git remote set-url --add origin http://github.com/user/repo
and
git push --set-upstream origin master
Earlier when I wasn't granted permission to access the repo, I had also added the SSH pubkey to gitlab. At the point I could access the repo and run go mod vendor, the same problem as your happens. (maybe because of cache)
go mod vendor
go: errors parsing go.mod:
/Users/macos/Documents/sample/go.mod:22: git ls-remote -q https://git.aaa.team/core/some_repo.git in /Users/macos/go/pkg/mod/cache/vcs/a94d20a18fd56245f5d0f9f1601688930cad7046e55dd453b82e959b12d78369: exit status 128:
fatal: could not read Username for 'https://git.aaa.team': terminal prompts disabled
After a while trying, I decide to remove the SSH key and terminal prompts filling in username and password. Everything is fine then!