How can I force user and password prompt when pushing to my git repository?

GitGithub

Git Problem Overview


I recently updated my local Git installation to 1.8.1 from 1.8.0.1.

I'm noticing that, when I work on GitHub, it doesn't prompt me for username and password on push anymore.

This troubles me, as I see having to type user and password every time as a good security measure. (what if someone else uses my computer?)

I checked the following:

  • 1.8.0.1 on another computer still asks for username and password.
  • my account on github still enforces private/security controls.
  • I am using https remote references, rather than ssh.
  • For good measure, I checked in my ~/.ssh fonder. Nothing wrong there.
  • I'm not storing the login details in ~/.gitconfig or individual <proj>/.git/config files.
  • I'm also not storing anything github-related in ~/.netrc.
  • I created a new dummy archive: still doesn't prompt me for login.

I couldn't find anything in the git release notes archive.

Does anyone know if this is a new git behaviour? How do I restore the prompt?

Git Solutions


Solution 1 - Git

Add a -v flag with your git command . e.g. git pull -v

> v stands for verify .

Solution 2 - Git

This is most likely because you have multiple accounts, like one private, one for work with GitHub.

SOLUTION On Windows, go to Start > Credential Manager > Windows Credentials and remove GitHub creds, then try pulling or pushing again and you will be prompted to relogin into GitHub

SOLUTION OnMac, issue following on terminal:

git remote set-url origin https://[email protected]/username/repo-name.git

by replacing 'username' with your GitHub username in both places and providing your GitHub repo name.

Solution 3 - Git

> With git config -l, I now see I have a credential.helper=osxkeychain option

That means the credential helper (initially introduced in 1.7.10) is now in effect, and will cache automatically the password for accessing a remote repository over HTTP.
(as in "GIT: Any way to set default login credentials?")

You can disable that option entirely, or only for a single repo.

Solution 4 - Git

None of those worked for me. I was trying to clone a directory from a private git server and entered my credentials false and then it wouldn't let me try different credentials on subsequent tries, it just errored out immediately with an authentication error.

What did work was specifying the user name (mike-wise)in the url like this:

   git clone https://[email protected]/someuser/somerepo.git

Solution 5 - Git

Since the question was labeled with Github, adding another remote like https_origin and add the https connection can force you always to enter the password:

git remote add https_origin https://github.com/.../...

Solution 6 - Git

Addition to third answer: If you're using non-english Windows, you can find "Credentials Manager" through "Control panel" > "User Accounts" > "Credentials Manager"

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontompaveView Question on Stackoverflow
Solution 1 - GitsapyView Answer on Stackoverflow
Solution 2 - GitpixelView Answer on Stackoverflow
Solution 3 - GitVonCView Answer on Stackoverflow
Solution 4 - GitMike WiseView Answer on Stackoverflow
Solution 5 - GitAfshin MehrabaniView Answer on Stackoverflow
Solution 6 - GitВладимир ШоминView Answer on Stackoverflow