114

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?

Liam
  • 27,717
  • 28
  • 128
  • 190
tompave
  • 11,952
  • 7
  • 37
  • 63
  • Do you have a `%HOME%\_netrc` file with your credential in it? (as in http://stackoverflow.com/questions/11021803/need-github-without-username-and-password/11022181#11022181) Or do you have some kind of credential caching activated? (as in http://stackoverflow.com/questions/6191985/git-http-securely-remember-credentials/12938677#12938677) Or are you working with GitHub for Windows? – VonC Feb 01 '13 at 10:01
  • Thanks. I'm working on OS X. I do have a `~/.netrc` file, but there isn't anything github related in there (forgot to mention that, adding it now). With `git config -l` I now see I have a `credential.helper=osxkeychain` option. Thanks, I'll read the manpages. Could you expand your comment as an answer? – tompave Feb 01 '13 at 10:44
  • Comment expanded as an answer, with links to references. – VonC Feb 01 '13 at 10:51
  • 7
    I used `git config --global --unset credential.helper` and `git config --system --unset credential.helper` and it brought back the login prompt. – yoyo Mar 07 '19 at 05:12
  • Note that "bring back the prompt" doesn't solve "what if someone else uses my computer?" worry — you also want to find & delete whereever the credential helper stored passwords (whether it's files or OS keychain) – Beni Cherniavsky-Paskin Nov 15 '22 at 15:15

8 Answers8

176

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

v stands for verify .

sapy
  • 8,952
  • 7
  • 49
  • 60
  • 2
    @joao I saw one of my colleague using this command , and I promptly remembered it . Never saw this anywhere documented as well . It looks more like --verbose flag , not sure why it works :) – sapy May 18 '16 at 17:52
  • yes . It caught my attention as well , it looks like verbose , or version ... But actally it stands for `verify` . Git has strange nomenclatures. – sapy Jan 12 '17 at 07:07
  • Perfect! Forces re-authentication as advertised. – Matt Brock Apr 24 '17 at 15:22
  • 13
    git version 1.7.1 man pages show that `-v` stands for verbose for `git-pull` and `git-fetch` – peter Apr 23 '19 at 20:33
  • 20
    Did absolutely nothing for me. Did not prompt for anything. Just pushed. –  Sep 18 '19 at 18:11
  • 1
    This should be the accepted answer. Straight to the point and it works. – tuan.dinh May 11 '20 at 01:00
  • 1
    This is the real answer, imho--with the -v option I re-entered my credentials and am all set. The reason I needed to reverify is because my corporate password had changed. – Scott Jul 31 '20 at 17:50
108

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://username@github.com/username/repo-name.git

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

or add the password/token as well

git remote set-url origin https://username:<pass/token>@github.com/username/repo-name.git
mPrinC
  • 9,147
  • 2
  • 32
  • 31
pixel
  • 9,653
  • 16
  • 82
  • 149
26

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    thanks. it took me a while because for some reason the option was in the `--system` config file, rather than in the `--global` one. Still wondering how that got switched on. – tompave Feb 01 '13 at 13:06
  • Had you installed GitExtensions or any other client, which switched it on? I dont remember switching it on until I installed GitExtensions. – RuntimeException Jun 08 '17 at 15:04
  • Apparently, this might be the cause. The credential cache daemon. Not sure if the same is the cause on Windows though. https://stackoverflow.com/a/15382950/15789 – RuntimeException Jun 08 '17 at 15:16
  • 1
    @RuntimeException on Windows, by default, the credential helper is the Microsoft Credential Manager (so, no daemon): https://stackoverflow.com/a/42152514/6309 – VonC Jun 08 '17 at 18:35
  • 2
    Thanks, this sent me on the right path. I launched the keychain access tool in OS X and just deleted all the github stuff there... Solved the problem. – Shai Almog Jul 17 '20 at 05:17
18

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://mike-wise@collab.somewhere.net/someuser/somerepo.git
Mike Wise
  • 22,131
  • 8
  • 81
  • 104
5

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/.../...
Afshin Mehrabani
  • 33,262
  • 29
  • 136
  • 201
  • 1
    This didn't work for me. I can add the https remote, but it still says 'permisson denied to ' without prompting me. – LondonRob Oct 17 '18 at 16:17
3

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

Liam
  • 27,717
  • 28
  • 128
  • 190
0

The easiest way to get around the dumb github restriction is making an api token under developer in your profile settings. Then you can change your repo url to be @url

pooshla
  • 552
  • 4
  • 9
0

deleting these lines in ~/.gitconfig save me :

    extraheader = Authorization: Bearer xxx
[remote "origin"]
    url = https://user:token@github.com/user/repo.git
[alias]
    credential-manager = credential-manager-core
[credential]
    helper = osxkeychain```
Makio64
  • 123
  • 1
  • 9