'Ask for username and password everytime I pull or push in Git
I am currently using git via command line. I need git to ask for username and password every time I push or pull my repository. Currently it just asks for password. Please help me here. The url in .git/config file is somewhat like this:
https://[email protected]/hello/folder.git
Solution 1:[1]
Unset credential before Pull/Push.
$ git config --unset credential.helper
$ git pull
Solution 2:[2]
Using git through ssh instead of https is one way to have passwordless authentication.
Here is a github manual page on the topic.
The steps (roughly) involve;
- Creating your own ssh key (
ssh-keygen -t rsa, leave the password blank) - Adding that public key to github (copy contents of
~/.ssh/id_rsa.pubas per these instructions - Cloning your repository using ssh instead of https.
I admit it takes a little bit of fiddling to get set up - but once done, you shouldn't have to do it again on that PC. That is, you can then clone any other repo on github (using the ssh clone) without needing to type any password.
Solution 3:[3]
git push https://github.com/user_name/repo_name.git
then give your id and password
user_name and repo_name you have to put.
Solution 4:[4]
You've indicated that the URL that you're using is:
You've put your username in the URL. The xxxxx portion of the URL is the username that you want to use for authentication. Since you've already provided it, Git will not prompt you for it. It will, however, prompt you for the password (though you could have included that in the URL as well, with the form https://xxxxx:[email protected]/hello/folder.git).
If you want to be prompted for both username and password, simply remove it from the URL:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Shadow |
| Solution 3 | Matthieu Brucher |
| Solution 4 | Edward Thomson |
