Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force git to prompt for credentials?

Weeks ago (and in a fog), I needed to make some changes to something hosted at github. I was directed by someone-who-knows-more-than-me (SWKMTM) via phone on exactly what to type in order to configure, pull down, modify, push back and then activate things. Part of this involved issuing instructions to git that said I as SWKMTM.

Now that I've had time to learn a bit about git/github (as well as to recall my github login information), I've gone back and tried to substitute my identity for SWKMTM on my client machine (a la git config --global user.name and git config --global user.email). After doing this, I can perform the same update activities as before. However, I have yet to be prompted to enter my github password (i.e., there is NO request to enter my github password). I'm assuming that something has been cached identifying me as SWKMTM (and that I must've done something in the earlier fog that involved entering SWKMTM's github password) -- either locally or by implicitly sending my SSH public key.

I've searched around in vain for .*rc files and configuration directories for anything that resembles credentials that might be associated with SWKMTM (in hopes of dispatching said credentials and forcing git to prompt for new ones). I've similarly failed to find anything at github that might tell if there is some sort of aliasing for public keys (and how it might be purged).

I've also tried the advised "git config -l" for any credential helper and have found none.

How can I force github to forget that I've been masquerading as SWKMTM?

[sidenote: this is on MacOS with no indication in config files that credential-osxkeychain is used. Only after using GIT_TRACE=1 on a push was it obvious where the credentialing was stored.]

like image 472
jhfrontz Avatar asked Sep 22 '13 19:09

jhfrontz


People also ask

In what scenario Git will prompt you to check credentials?

Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username and password in order to access a remote repository over HTTP.

How do I authenticate my credentials in Git?

There are three main approaches you can take: Using a personal authentication token or password. Using an SSH key. Using your GitHub password with 2-factor authentication.

What could be the possible reason for Git prompting for credentials?

If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository. Using an HTTPS remote URL has some advantages compared with using SSH. It's easier to set up than SSH, and usually works through strict firewalls and proxies.


1 Answers

user.name and user.email have nothing to do with credentials, they are just strings that are put into each commit you make to store your authorship information.

Git normally authenticates you via SSH, so you have to either copy your SSH private key from the other machine to your new client, or create a new key pair and add the public part to your github profile.


OK, after extensive discussion in the chat it turns out that Git was using the osxkeychain credential helper which provided previously stored credentials.

Remove your stored credentials from your OSX keychain or disable the crendential helper (credential.helper config option) in Git to be prompted for authentication again.

like image 80
knittl Avatar answered Oct 16 '22 11:10

knittl