0

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://xxxxx@github.com/hello/folder.git
Mithila
  • 11
  • 4
  • 1
    If you use ssh instead of https to access the git repository, you can skip authentication by using ssh keys instead of interactive authentication. – Shadow Feb 27 '17 at 05:03
  • 2
    Possible duplicate of [Is there a way to skip password typing when using https:// on GitHub?](http://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-on-github) – Shadow Feb 27 '17 at 05:05
  • How do I use ssh? – Mithila Feb 27 '17 at 05:25
  • I'll add the documentation as an answer. – Shadow Feb 27 '17 at 05:26

5 Answers5

1

Unset credential before Pull/Push.

$ git config --unset credential.helper

$ git pull
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
0

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;

  1. Creating your own ssh key (ssh-keygen -t rsa, leave the password blank)
  2. Adding that public key to github (copy contents of ~/.ssh/id_rsa.pub as per these instructions
  3. 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.

Shadow
  • 8,749
  • 4
  • 47
  • 57
  • This is the opposite of what OP wants, quoting: _"I need git to ask for username and password every time I push or pull my repository"_ – 1615903 Feb 27 '17 at 07:30
  • ... good point. Guess I didn't read it correctly. Doesn't git already do this by default if you're using https? – Shadow Feb 27 '17 at 09:40
0
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.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
Joy
  • 41
  • 1
  • 6
0

You've indicated that the URL that you're using is:

https://xxxxx@github.com/hello/folder.git

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:password@github.com/hello/folder.git).

If you want to be prompted for both username and password, simply remove it from the URL:

https://github.com/hello/folder.git

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
0

Setting the credential helper works for me.
Simply type the following and hit enter: git config --global credential.helper store