fatal: could not read Username for 'https://github.com': No such file or directory
Solution 1:
Follow the steps to setup SSH keys here: https://help.github.com/articles/generating-ssh-keys
OR
git remote add origin https://{username}:{password}@github.com/{username}/project.git
Update: If you get "fatal: remote origin already exists." then you have to use set-url:
git remote set-url origin https://{username}:{password}@github.com/{username}/project.git
Solution 2:
I faced the exact same problem. This problem occurred when I cloned using HTTPS URL and then tried to push the changes using Git Bash on Windows using:
git clone https://github.com/{username}/{repo}.git
However, when I used SSH URL to clone, this problem didn't occur:
git clone [email protected]:{username}/{repo}.git
Solution 3:
I found my answer here:
edit ~/.gitconfig
and add the following:
[url "[email protected]:"]
insteadOf = https://github.com/
Although it solves a different problem, the error code is the same...
Solution 4:
For me nothing worked from suggested above, I use the git pull
command from Jenkins Shell Script and apparently it takes wrong user name. I spent ages before I found a way to fix it without switching to SSH.
In your the user's folder create .gitconfig file (if you don't have it already) and put your credentials in following format: https://user:[email protected]
, more info. After your .gitconfig file link to those credentials, in my case it was:
[credential]
helper = store --file /Users/admin/.git-credentials
Now git will always use those credentials no matter what. I hope it will help someone, like it helped me.