Created a PAT, but git keeps sending a password #23909
-
I normally use TortoiseGit for GitHub access (using Windows10). Today, after getting messages about passwords no longer being accepted, I created a wincred PAT, cleared the saved authentication data cache from TortoiseGit, then tried to do a push. But GitHub complains that git is still trying to send a password. I’m not really familiar with the git command line commands. I’ve been reading the docs for quite a while now, but not getting anywhere. I installed the latest git version. My global .gitconfig file has these entries: [credential “https://github.com”] Can someone help me get git to start using the PAT instead of a password? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments
-
I’m watching this thread, feel free to watch mine in case I get a solution from someone. I did get some advice but it did not solve it for me. Good luck! |
Beta Was this translation helpful? Give feedback.
-
It seems that my password is cached somewhere and git is sending it automatically. I need to delete this, so that I can get it to prompt for credentials and input the PAT that I have created. But I cannot find where the password is cached. I’ve looked in the Windows Credentials Manager but there are no entries there for git. I don’t see a password cached in any of the .git config files. I’m really stuck. How can I purge this cached password? When I installed git I also installed Git Credential Manager Core. Is it possibly cached there? I don’t know to how I can tell. |
Beta Was this translation helpful? Give feedback.
-
eygilbert:
Yes, that’s indeed the case. https://git-scm.com/docs/git-credential-store
eygilbert:
Possibly, if you have enabled Git to use that instead of its default credentials tool. A good file to check is If not, you’ll have to query your Git configuration to check which credentials manager it’s using, and where it might be storing them: |
Beta Was this translation helpful? Give feedback.
-
Tajmone, thanks. I don’t find a .git-credentials file anywhere. [credential] I queried the gcm-core version: d:\projects>git credential-manager-core --version After reading the docs about gcm-core, it looks like I need to send the erase command, although I’m not sure, it’s not at all clear to me what I should do. Anyway, I tried this: d:\projects>git credential-manager-core erase But it still has the password cached. Can you tell me what the commands should be to erase the password? The docs for gcm-core say this about the commands get / store / erase: “Commands for interaction with Git. You shouldn’t need to run these manually.” Which makes me think I’m looking in the wrong place. |
Beta Was this translation helpful? Give feedback.
-
On your device type in credential manager on windows search anf launch app. Select the correct tab and delete the entry referring to git. |
Beta Was this translation helpful? Give feedback.
-
If you are still using an existing cached password for you login you will need to remove it, the below will help, hopefully slight_smile Launch ‘Credential Manager’ on your Windows device. Switch to tab Windows Credentials (it default displayed tab Web Credentials on my device). A list of locally cached credentials are then shown Find an entry starting something like git:htttps//login@github.com (this will be an exist cached entry for your username/password. You can safely delete this by … |
Beta Was this translation helpful? Give feedback.
-
Thank you byrneh. I have looked at all the Windows credentials listed in Credential Manager, and none of them are anything related to git. |
Beta Was this translation helpful? Give feedback.
-
@eygilbert are you using git command line or Tortoise Git? I don’t use Tortoise Git but I am told this suggestion may work. |
Beta Was this translation helpful? Give feedback.
-
I normally use TortoiseGit, but since my problem seems to be with the underlying command-line git, I have been working with that to try to solve the problem. Installing TortoiseGit requires that I also install the command-line git.
d:\projects>git version d:\projects>git config --list --show-origin
Here is the entry from the config file of one of my repos:
It’s not in the format that you gave. I’m not sure how to proceed from there. Should I simply replace my username with username:access_token in the line below?
|
Beta Was this translation helpful? Give feedback.
-
Ah, I misunderstood your suggestion. I edited the config file to look like this:
and now I am able to push to this repos. Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
I finally found the root cause of my problem. The github username and password were cached in a _netrc file in my Documents directory. What’s really insidious is that none of the git commands seemed to be able to either display or delete this cache. With this problem fixed, git is now using the PAT stored in Windows Credential manager, and I don’t have to edit the remote origin url in every config file of every local repository to make authentication work. |
Beta Was this translation helpful? Give feedback.
-
eygilbert:
Excellent! Mark your solution as the Solution, so other users can quickly find it and benefit from it. |
Beta Was this translation helpful? Give feedback.
-
Thanks, it’s that. However I have two entries for Github… Grrr |
Beta Was this translation helpful? Give feedback.
-
Hi @Naheulf! Nice to see you here on the Community Forum! (I’ve just labeled your PR for the French docs, thanks!) |
Beta Was this translation helpful? Give feedback.
-
I had a similar problem. It turned out to be I had 2 entries in the windows credential manager: one for https://myusername@xxx,gitlab.com, the other just for https://xxx,gitlab.com, or I think that was the reason. deleting one seems to have fixed the issue, but who knows? |
Beta Was this translation helpful? Give feedback.
I finally found the root cause of my problem. The github username and password were cached in a _netrc file in my Documents directory. What’s really insidious is that none of the git commands seemed to be able to either display or delete this cache. With this problem fixed, git is now using the PAT stored in Windows Credential manager, and I don’t have to edit the remote origin url in every config file of every local repository to make authentication work.