Mithila
Mithila

Reputation: 11

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

Upvotes: 0

Views: 3720

Answers (6)

Muhammad Waris
Muhammad Waris

Reputation: 7

I was facing the same issue and solved it using these two commands:

git config --global credential.https://github.com.username username
git config --global credential.https://github.com.email [email protected]

Try to use these two commands
username => actual user name of your profile

[email protected] => actual github account email

Upvotes: 0

Ayomide Suara
Ayomide Suara

Reputation: 97

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

Upvotes: 1

Edward Thomson
Edward Thomson

Reputation: 78623

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

https://[email protected]/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:[email protected]/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

Upvotes: 0

Joy
Joy

Reputation: 41

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.

Upvotes: 0

Sajib Khan
Sajib Khan

Reputation: 24136

Unset credential before Pull/Push.

$ git config --unset credential.helper

$ git pull

Upvotes: 1

Shadow
Shadow

Reputation: 9427

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.

Upvotes: 0

Related Questions