786

I'm working with several repositories, but lately I was just working in our internal one and all was great.

Today I had to commit and push code into other one, but I'm having some troubles.

$ git push appharbor master
error: The requested URL returned error: 403 while accessing https://gavekortet@appharbor.com/mitivo.git/info/refs?service=git-receive-pack
fatal: HTTP request failed

There is nothing I can do, that would bring the password entry again.

How can I reset the credentials on my system so Git will ask me for the password of that repository?

I have tried:

  • git config --global --unset core.askpass

in order to unset the password

  • git config credential.helper 'cache --timeout=1'

in order to avoid credentials cache...

Nothing seems to work; does anyone have a better idea?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
balexandre
  • 69,002
  • 44
  • 219
  • 321
  • Do you have a `~/.netrc` file? – robinst Mar 13 '13 at 09:29
  • 3
    @robinst it's a windows machine, and I can't find that file, not even from Git Bash... – balexandre Mar 13 '13 at 10:30
  • @balexandre for a Windows machine, I prefer using the new (git 1.8.3) credential helper `netrc`, which would store *multiple* credential in an *encrypted* file. It is better than entering your password each time for each session, since the cache only "caches" the password for a certain time. See a [full example here](http://stackoverflow.com/a/18362082/6309). – VonC Aug 22 '13 at 13:18
  • I don't have .netrc. I do have a file in ~ (C:\Users\Myself) named .git-credentials, but erasing it didn't work, I'm still logged into Git Shell. Also, the Control Panel Credential Manager doesn't seem to be storing anything. Local and global Git config files seems ok. I inherited my workstation from an employee that left, so it could be that he set-up some unorthodox credential caching mechanism that I have no clue how to turn off. I hope this behavior IS NOT the default of Git Windows. On Mac credential caching is the default but at least it shows up in Keychain Access. – damix911 Nov 18 '15 at 11:00
  • A fuller answer which also works on linux, windows and Mac OS X see http://stackoverflow.com/a/39944557/3906760 – MrTux Oct 09 '16 at 15:07
  • people concerned about security may want to ensure this `rm ~/.git-credentials` afterwards. Being prompted for a password doesn't mean that they are not stored. – ribamar Jun 18 '18 at 13:15
  • (note that this is not enough to erase the password) – ribamar Jun 18 '18 at 13:32

36 Answers36

948

If this problem comes on a Windows machine, do the following.

  • Go to Credential Manager

    • in German, it is called: Anmeldeinformationsverwaltung
    • in French, it is called: Gestionnaire d'identification
    • in Polish, it is called: Menedżer poświadczeń
    • in Russian, it is called: Диспетчер учётных данных

    Go to Credential Manager

  • Go to Windows Credentials

  • Delete the entries under Generic Credentials

    Go to Windows Credentials and Delete the entries under Generic Credentials

  • Try connecting again. This time, it should prompt you for the correct username and password.

naXa
  • 26,677
  • 15
  • 154
  • 213
Venkataramana Madugula
  • 10,165
  • 2
  • 15
  • 22
  • 7
    This is only relevant if your `credential.helper=manager`. To test this type `git config --list`. If it's set to `store` then credentials are not stored in the credentials store but are stored un-encrypted. – Liam Dec 14 '17 at 10:48
  • 6
    I only had to delete the credential named `git:https://github.com` and I was prompted to enter my username/pass the next time I cloned a repo using PyCharm. I had more than one github account and the wrong one was cached. – dotcomly Jan 17 '18 at 18:36
  • 30
    If someone is searching this on a german localized machine, it is _"Anmeldeinformationsverwaltung"_ on path `Systemsteuerung\Alle Systemsteuerungselemente\Anmeldeinformationsverwaltung`. – davidenke Jan 31 '18 at 08:14
  • 4
    Alternatively you can change the user/pass in the `Credential Manager`. That worked for me too – Daniel Lerps Jul 31 '18 at 11:46
  • Deleting the credentials solved my `403` error via Bitbucket. – Eido95 Dec 30 '18 at 23:38
  • 1
    for all german users: Systemsteuerung\Benutzerkonten\Anmeldeinformationsverwaltung – phirzel Jun 25 '19 at 13:02
  • In french: "Credential manager" = "Gestionnaire d'identification" – sthiers Apr 08 '20 at 06:51
  • 3
    If you're unable to get to credential manager via Windows you can run this from the command prompt to access it: rundll32.exe keymgr.dll,KRShowKeyMgr – chonerman Jun 25 '20 at 15:16
  • Thanks for this. I've been trying to figure this out for a month! – ScienceofSpock Aug 05 '20 at 20:55
  • In Dutch (or Nederlands, for googlability) you have to look for `Referentiebeheer` on path `Configuratiescherm\Gebruikersaccounts\Referentiebeheer`. – Br2 Jan 08 '21 at 08:52
  • In Norwegian: "Legitimasjonsbehandling" – Halvor Holsten Strand Mar 23 '21 at 22:11
  • if in the search result, it is not coming. Go to control panel, search it there (right side top) – P Satish Patro Apr 26 '21 at 17:33
718

The Git credential cache runs a daemon process which caches your credentials in memory and hands them out on demand. So killing your git-credential-cache--daemon process throws all these away and results in re-prompting you for your password if you continue to use this as the cache.helper option.

You could also disable use of the Git credential cache using git config --global --unset credential.helper. Then reset this, and you would continue to have the cached credentials available for other repositories (if any). You may also need to do git config --system --unset credential.helper if this has been set in the system configuration file (for example, Git for Windows 2).

On Windows you might be better off using the manager helper (git config --global credential.helper manager). This stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. With this store, your details are secured by your Windows login and can persist over multiple sessions. The manager helper included in Git for Windows 2.x has replaced the earlier wincred helper that was added in Git for Windows 1.8.1.1. A similar helper called winstore is also available online and was used with GitExtensions as it offers a more GUI driven interface. The manager helper offers the same GUI interface as winstore.

Extract from the Windows 10 support page detailing the Windows credential manager:

To open Credential Manager, type "credential manager" in the search box on the taskbar and select Credential Manager Control panel.

And then select Windows Credentials to edit (=remove or modify) the stored git credentials for a given URL.

Community
  • 1
  • 1
patthoyts
  • 29,437
  • 2
  • 54
  • 84
  • Is this the winstore helper you mentioned? https://gitcredentialstore.codeplex.com/ – Michiel van Oosterhout Aug 04 '14 at 09:22
  • 200
    I found the Windows Credential control panel at `Control Panel\User Accounts\Credential Manager` under Windows 7 – Steve Pitchers Apr 30 '15 at 13:04
  • 2
    Doesn't killing the process leave any traces somewhere, so that the password could be still accessed? According to git manual they are stored in "plain text". – Ufos Jan 19 '16 at 13:40
  • The git-credential-cache helper stores things in current memory. Something might end up in the system pagefile but it is no more readable that it was while the process was running. – patthoyts Jan 19 '16 at 21:56
  • 1
    Under windows 8.1 the "Windows Credentials" was under Generic Credentials and git:https://gitlab.com or your git server of choice. – Jeff Apr 21 '16 at 16:34
  • 5
    Under Windows 8/10 the detailed User Account Settings are located under the "classic" Controll Panel, *not* the "Settings" App (modern UI). Just to avoid confusion. – DanielH Jun 08 '16 at 09:32
  • "helper=wincred" was the hint. It was not listed in the git online book. – dsuess Sep 07 '16 at 14:29
  • I would +1 for your last edit (if I did not already upvoted that answer a long time ago): the "manager" credential helper rocks! – VonC Oct 21 '16 at 19:00
  • On a windows box just do this: git config --global credential.helper manager. No need for anything else. – Display name Dec 27 '17 at 15:44
  • 1
    in windows 10 Go to Control Panel\All Control Panel Items\Credential Manager . There could be a Generic Credential for GitHub. You can update the user name and password there. – Eldhose Abraham Jan 05 '18 at 07:01
  • killing the process still leaves traces. at least in `1.9.1`. be careful. – ribamar Jun 18 '18 at 13:31
  • git config --system --unset credential.helper helped me on mac – setshaft Jan 31 '19 at 05:23
  • referentiebeheer in dutch – shotor Jul 30 '19 at 14:36
  • please update your comment to point out that if we are using Windows and if the commands dont seem to work we need to open a GitBash as Administrator and run them there, this is how I got them to work – Божидар Йовчев Sep 23 '19 at 20:59
167

Retype:

$ git config credential.helper store

And then you will be prompted to enter your credentials again.

WARNING

Using this helper will store your passwords unencrypted on disk

Source: https://git-scm.com/docs/git-credential-store

aaafly
  • 2,408
  • 1
  • 12
  • 10
140

I faced the same issue as the OP. It was taking my old Git credentials stored somewhere on the system and I wanted to use Git with my new credentials, so I ran the command

$ git config --system --list

It showed

credential.helper=manager

Whenever I performed git push it was taking my old username which I set long back, and I wanted to use new a GitHub account to push changes. I later found that my old GitHub account credentials was stored under Control PanelUser AccountsCredential ManagerManage Windows Credentials.

Manage Windows Credentials

I just removed these credentials and when I performed git push it asked me for my GitHub credentials, and it worked like a charm.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Mourya
  • 2,080
  • 2
  • 15
  • 22
  • Good illustration of the recent of the recent Git Credential Manager (https://github.com/Microsoft/Git-Credential-Manager-for-Windows) which works by storing credentials (https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/31) +1 – VonC Sep 20 '16 at 11:25
  • 2
    @VonC It took me a day to find out this as i wasn't aware of this mechanism of storing credentials. – Mourya Sep 20 '16 at 14:00
  • It is fairly recent indeed. Thank you for mentioning it here. – VonC Sep 20 '16 at 16:21
  • This is probably the better answer than the "accepted" one, which to me implies nuking all credentials. Definitely helped me. – VictorLegros May 19 '20 at 16:40
  • [Git Credential Manager Core](https://github.com/microsoft/Git-Credential-Manager-Core) is the more recent and default credential manager. In recent versions of Git `git config --global --list` should now return `credential.helper=manager-core` and not `credential.helper=manager` – Asif Kamran Malick Mar 24 '21 at 20:41
  • Thanks a lot, this works! We can also click the Edit and update the password. – Frank May 06 '21 at 14:26
57

Try using the below command.

git credential-manager

Here you can get various options to manage your credentials (check the below screen).

Enter image description here

Or you can even directly try this command:

git credential-manager uninstall

This will start prompting for passwords again on each server interaction request.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
  • 17
    Why am I getting - `git: 'credential-manager' is not a git command. See 'git --help'.` – Saikat Aug 29 '17 at 08:02
  • 2
    Not sure, why isn't it working for you, but even in latest git version, it's available. Please refer this link for more info - https://git-scm.com/book/gr/v2/Git-Tools-Credential-Storage – Himanshu Aggarwal Sep 07 '17 at 16:48
  • 3
    Got ```removal failed. U_U Press any key to continue... fatal: InvalidOperationException encountered. Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.``` (with the nice `U_U` emoji out of nowhere :)) – jeromej Dec 30 '17 at 16:33
  • 1
    The only solution that worked for me on Windows with GitBash. – alain.janinm Nov 19 '18 at 14:40
  • maybe an aside, but i installed git via choco, and this [uninstall] method was good for me for pulling a repo on a deployed computer without storing credentials – beep_check Apr 17 '20 at 01:54
38

I found something that worked for me. When I wrote my comment to the OP I had failed to check the system config file:

git config --system -l

shows a

credential.helper=!github --credentials

line. I unset it with

git config --system --unset credential.helper

and now the credentials are forgotten.

Jaap
  • 476
  • 8
  • 15
damix911
  • 3,717
  • 26
  • 39
  • 3
    Ankur, you may need to run the suggested command in similar ways from 2-3 times if you have gotten a couple credential helpers configured. `git config --global --unset credential.helper` and maybe just `git config --unset credential.helper` in your repository if you had somehow set it explicitly there. – dragon788 Sep 26 '16 at 21:57
  • 1
    thanks for the solution. Just a detail : in my case I had to launch the command prompt as an administrator – A.Joly Mar 03 '20 at 08:11
  • 1
    only this helped on mac – merdan Aug 25 '20 at 09:33
32

In my case, Git is using Windows to store credentials.

All you have to do is remove the stored credentials stored in your Windows account:

Windows credentials menu

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
SoliQuiD
  • 1,717
  • 18
  • 26
30
git config --list

will show credential.helper = manager (this is on a windows machine)

To disable this cached username/password for your current local git folder, simply enter

git config credential.helper ""

This way, git will prompt for password every time, ignoring what's saved inside "manager".

Zhe Hu
  • 3,101
  • 4
  • 27
  • 38
  • I have the error below, `git: 'credential-' is not a git command. See 'git --help'.`, but for security I am upvoting this answer because it is the only one that made me be prompted for a new password. I am wondering, however, if this is not just masking the problem (is the password really removed?) – ribamar Jun 18 '18 at 13:07
  • Nope: `rm -rf ~/.git-credentials` did. Note that it can vary (`git help credential-store`) – ribamar Jun 18 '18 at 13:09
  • sorry, this really doesn't work. it will ask for the password once more and store it again. would remove my upvote if allowed. – ribamar Jun 18 '18 at 13:25
  • `git config --unset credential.helper` clears the entry. This answer just sets it to empty string and produces the error that @ribamar described in comments. – Dark Castle Jan 03 '19 at 18:56
  • This works for me! – Sir iPad Newton Jan 12 '21 at 07:59
29

You have to update it in your Credential Manager.

Go to Control Panel > User Accounts > Credential Manager > Windows Credentials. You will see Git credentials in the list (e.g. git:https://). Click on it, update the password, and execute git pull/push command from your Git bash and it won't throw any more error messages.

Stephen Rauch
  • 40,722
  • 30
  • 82
  • 105
ChiragBhalgami
  • 631
  • 5
  • 6
  • works for me in Windows 10, and no need to restart my IDE – Oleksandr H Jun 15 '20 at 07:06
  • Thanks! I had trouble removing some incorrect Git credentials because I was in a locked-down University computer without admin privileges. This solution worked. – OscarVanL Oct 27 '20 at 20:44
27

This error appears when you are using multiple Git accounts on the same machine.

If you are using macOS then you can remove the saved credentials of github.com.

Please follow below steps to remove the github.com credentials.

  1. Open Keychain Access
  2. Find github
  3. Select the github.com and Right click on it
  4. Delete "github.com"
  5. Try again to Push or Pull to git and it will ask for the credentials.
  6. Enter valid credentials for repository account.
  7. Done

    enter image description here

brian d foy
  • 121,466
  • 31
  • 192
  • 551
Pratik Patel
  • 1,424
  • 2
  • 16
  • 28
20

In Windows 2003 Server with "wincred"*, none of the other answers helped me. I had to use cmdkey.

  • cmdkey /list lists all stored credentials.
  • cmdkey /delete:Target deletes the credential with "Target" name.

cmdkey /list; cmdkey /delete:Target

(* By "wincred" I mean git config --global credential.helper wincred)

ericbn
  • 8,345
  • 3
  • 40
  • 47
  • Yes, `cmdkey` is the command-line counterpart to the Windows Credentials described in the chosen answer. – nicobo Apr 21 '20 at 19:57
15

Got same error when doing a 'git pull' and this is how I fixed it.

  1. Change repo to HTTPS
  2. Run command git config --system --unset credential.helper
  3. Run command git config --system --add credential.helper manager
  4. Test command git pull
  5. Enter credentials in the login window that pops up.
  6. Git pull completed successfully.
Daniel Fisher lennybacon
  • 2,867
  • 1
  • 24
  • 31
Amer Bashoeb
  • 171
  • 1
  • 4
13

In case Git Credential Manager for Windows is used (which current versions usually do):

git credential-manager clear

This was added mid-2016. To check if credential manager is used:

git config --global credential.helper
→ manager
Simon A. Eugster
  • 3,732
  • 4
  • 32
  • 31
13

Need to login with respective github username and password

To Clear the username and password in windows

Control Panel\User Accounts\Credential Manager

Edit the windows Credential

Remove the existing user and now go to command prompt write the push command it shows a github pop-up to enter the username/email and password .

Now we able to push the code after switching the user.

Amit K
  • 171
  • 1
  • 4
13

Using latest version of git for Windows on Windows 10 Professional and I had a similar issue whereby I have two different GitHub accounts and also a Bitbucket account so things got a bit confusing for VS2017, git extensions and git bash.

I first checked how git was handling my credentials with this command (run git bash with elevated commands or you get errors):

git config --list

I found the entry Credential Manager so I clicked on the START button > typed Credential Manager to and left-clicked on the credential manager yellow safe icon which launched the app. I then clicked on the Windows Credentials tabs and found the entry for my current git account which happened to be Bit-bucket so I deleted this account.

But this didn't do the trick so the next step was to unset the credentials and I did this from the repository directory on my laptop that contains the GitHub project I am trying to push to the remote. I typed the following command:

git config --system --unset credential.helper

Then I did a git push and I was prompted for a GitHub username which I entered (the correct one I needed) and then the associated password and everything got pushed correctly.

I am not sure how much of an issue this is going forward most people probably work off the one repository but I have to work across several and using different providers so may encounter this issue again.

Community
  • 1
  • 1
Trevor
  • 1,294
  • 1
  • 16
  • 23
12

Remove this line from your .gitconfig file located in the Windows' currently logged-in user folder:

[credential]
helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"

This worked for me and now when I push to remote it asks for my password again.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Liviu Mandras
  • 6,314
  • 1
  • 38
  • 61
10

In my case, I couldn't find the credentials saved in the Windows Credential Manager (Windows 7).

I was able to reset my credentials by executing

git config --global credential.helper wincred

It was honestly a hail Mary to see if it would wipe out my credentials and it actually worked.

Jeff LaFay
  • 11,884
  • 12
  • 70
  • 97
10

If you want git to forget old saved credentials and re-enter username and password, you can do that using below command:

git credential-cache exit

After running above command, if you try to push anything it will provide option to enter username and password.

amitshree
  • 1,604
  • 2
  • 20
  • 36
9
  1. Go to C:\Users\<current-user>
  2. check for .git-credentials file
  3. Delete content or modify as per your requirement
  4. Restart your terminal
Dinesh Patil
  • 751
  • 8
  • 11
8

On Windows, at least, git remote show [remote-name] will work, e.g.

git remote show origin
Jason S
  • 171,795
  • 155
  • 551
  • 900
7

You can remove the line credential.helper=!github --credentials from the following file C:\Program Files\Git\mingw64\etc\gitconfig in order to remove the credentials for git

Liam
  • 22,818
  • 25
  • 93
  • 157
Yoan Pumar
  • 96
  • 1
  • 3
7

If your credentials are stored in the credential helper (generally the case), the portable way to remove a password persisted for a specific host is to call git credential reject:

  • in one line:

    $ echo "url=https://appharbor.com" | git credential reject
    
  • or interactively:

    $ git credential reject
    protocol=https
    host=gitlab.com
    username=me@example.com
    ↵
    
    • ↵ is the Enter symbol, just hit Enter key twice at the end of input, don't copy/paste it
    • The username doesn't seem recognized by wincred, so avoid to filter by username on Windows

After that, to enter your new password, type git fetch.

https://git-scm.com/docs/git-credential

Marsu
  • 496
  • 4
  • 8
6

For macOS users :

This error appears when you are using multiple Git accounts on the same machine.

Please follow below steps to remove the github.com credentials.

  1. Go to Finder
  2. Go to Applications
  3. Go to Utilities Folder
  4. Open Keychain Access
  5. Select the github.com and Right click on it

Delete "github.com"

Try again to Push or Pull to git and it will ask for the credentials. Enter valid credentials for repository account. Done

Suraj Chandgude
  • 101
  • 1
  • 8
4

This approach worked for me and should be agnostic of OS. It's a little heavy-handed, but was quick and allowed me to reenter credentials.

Simply find the remote alias for which you wish to reenter credentials.

$ git remote -v 
origin  https://bitbucket.org/org/~username/your-project.git (fetch)
origin  https://bitbucket.org/org/~username/your-project.git (push)

Copy the project path (https://bitbucket.org/org/~username/your-project.git)

Then remove the remote

$ git remote remove origin

Then add it back

$ git remote add origin https://bitbucket.org/org/~username/your-project.git
Josh
  • 584
  • 5
  • 9
3

What finally fixed this for me was to use GitHub desktop, go to repository settings, and remove user:pass@ from the repository url. Then, I attempted a push from the command line and was prompted for login credentials. After I put those in everything went back to normal. Both Visual Studio and command line are working, and of course, GitHub desktop.

GitHub Desktop->Repository->Repository Settings->Remote tab

Change Primary Remote Repository (origin) from:

https://pork@muffins@github.com/MyProject/MyProject.git

To:

https://github.com/MyProject/MyProject.git

Click "Save"

Credentials will be cleared.

  • Resetting the origin to the same one from the command line on Windows has solved my issue. I'm using GitLab so I couldn't use GitHub Desktop for this. – David Vargas Nov 19 '19 at 10:24
3

Building from @patthoyts's high-voted answer (https://stackoverflow.com/a/15382950/4401322):

His answer uses but doesn't explain "local" vs. "global" vs. "system" configs. The official git documentation for them is here and worth reading.

For example, I'm on Linux, and don't use a system config, so I never use a --system flag, but do commonly need to differentiate between --local and --global configs.

My use case is I've got two Github crendentials; one for work, and one for play.

Here's how I would handle the problem:

$ cd work
# do and commit work
$ git push origin develop
# Possibly prompted for credentials if I haven't configured my remotes to automate that. 
# We're assuming that now I've stored my "work" credentials with git's credential helper.

$ cd ~/play 
# do and commit play
$ git push origin develop                                                                   
remote: Permission to whilei/specs.git denied to whilei.                
fatal: unable to access 'https://github.com/workname/specs.git/': The requested URL returned error: 403

# So here's where it goes down:
$ git config --list | grep cred
credential.helper=store # One of these is for _local_
credential.helper=store # And one is for _global_

$ git config --global --unset credential.helper
$ git config --list | grep cred
credential.helper=store # My _local_ config still specifies 'store'
$ git config --unset credential.helper
$ git push origin develop
Username for 'https://github.com': whilei
Password for 'https://whilei@github.com':
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.10 KiB | 1.10 MiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/whilei/specs.git
   b2ca528..f64f065  master -> master

# Now let's turn credential-helping back on:
$ git config --global credential.helper "store"
$ git config credential.helper "store"
$ git config --list | grep cred
credential.helper=store # Put it back the way it was.
credential.helper=store

It's also worth noting that there are ways to avoid this problem altogether, for example, you can use ~/.ssh/config's with associated SSH keys for Github (one for work, one for play) and correspondingly custom-named remote hosts to solve authentication contextualizing too.

irbanana
  • 700
  • 8
  • 19
3

For Windows 10, go to below path,

Control Panel\User Accounts\Credential Manager

There will be 2 tabs at this location,

  1. Web credentials and 2. Windows credentials.

Click on Windows credentials tab and here you can see your stored github credentials, under "Generic credentials" heading.

You can remove those from here and try and re-clone - it will ask for username/password now as we have just removed the stored credential from the Windows 10 systems

AADProgramming
  • 5,124
  • 11
  • 32
  • 56
3

To add to @ericbn 's https://stackoverflow.com/a/41111629/579827 here are sample commands I've embedded in a script I run to update all my passwords whenever they are renewed. It's probably not usable as-is as it's quite specific but it shows real life usage of cmdkey.exe.

⚠ This is a shell script run in cygwin

⚠ This works because I use private git repos that all authenticate with the same password (you probably don't want to loop over with the same credentials, but you may reuse this sample /list command to extract a list of already registered credentials) ⚠

entries=`cmdkey.exe /list: | grep git | sed -r -e 's/^[^:]+:\s*(.*)$/\1/gm'`
for entry in ${entries}
do
    cmdkey.exe "/delete:${entry}"
    cmdkey.exe "/generic:${entry}" "/user:${GIT_USERNAME}" "/pass:${GIT_PASSWORD}"
done
Community
  • 1
  • 1
nicobo
  • 550
  • 4
  • 7
2

In our case, clearing the password in the user's .git-credentials file worked for us.

c:\users\[username]\.git-credentials
Fares
  • 619
  • 5
  • 11
2

Execute the following command in a PowerShell console to clear Git Credentials Managers for Windows cache:

rm $env:LOCALAPPDATA\GitCredentialManager\tenant.cache

or in Cmd.exe

rm %LOCALAPPDATA%\GitCredentialManager\tenant.cache
Chris F Carroll
  • 7,909
  • 2
  • 42
  • 51
2

Try this when nothing as mentioned above is working for you.

git config credential.helper 'cache --timeout=30'

this will remove the cache every 3sec and will ask for username and password.You can re-run the command with increased timeout values.

manish kumar
  • 3,629
  • 2
  • 30
  • 44
1

Update Actually useHttpPath is a git configuration, which should work for all GCMs. Corrected.

Summary of The Original Question

  • working with git on Windows
  • working on multiple repositories on GitHub
  • wrong credentials used for another GitHub repository

Although the title says "Remove credentials", the description leads me to the assumption that you may have multiple accounts on GitHub, e.g. for job-related vs. private projects. (At least that issue made me find this topic.) If so read on, otherwise ignore the answer, but it may come in handy at some time.

Reason

Git Credential Managers (short GCM) like Microsoft's GCM for Windows store credentials per host by default. This can be verified by checking the Windows Credential Manager (see other answers how to access it on English, French and German Windows versions). So working with multiple accounts on the same host (here github.com) is not possible by default.

In October 2020 GCM for Windows got deprecated and superseeded by GCM Core. The information here still applies for the new GCM and it should even use the credentials stored by GCM for Windows.

Solution

Configure git to include the full path to the repository as additional information for each credential entry. Also documented on GCM for Windows.
I personally prefer to include the HTTP(S) [repository] path to be able to use a separate account for each and every repository.

For all possible hosts:

git config --global credential.useHttpPath true

For github.com only:

git config --global credential.github.com.useHttpPath true

Have a look at the GCM and git docs and maybe you want to specify something different.

Maddes
  • 71
  • 1
  • 3
0

If you are authenticated using your key pair, you can deleting or moving your private key, or stopping the key agent and trying.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Munim
  • 5,748
  • 2
  • 30
  • 41
0

As Mentioned by Everyone above, This is a Git Credential Manager Issue. Due to permissions, I could not modify my credentials or manipulate the credential manager. I also could not afford to sit password in plain text on pc. A workaround was deleting the remote branch in intellij and re-adding the remote branch. This removes the stored credential and forces refreshing of the credential.

enter image description here

Akin Okegbile
  • 969
  • 20
  • 33
  • 1
    as you see from other answers, you could simply remove the certificate in your windows certificate store, it's the easiest way. sometimes you can't simply remote the remote as the password is already stored in the certificate cache, and the next time you add the same remote, it will use the cached certificate – balexandre Dec 03 '18 at 20:54
  • I assume you might be using the word "certificate" instead of "credential". Due to policies on my PC; I do not have access to my "credential" store as I described in my post. I could not actually remove them. What invalidated them was removing the remote branch and re-adding it. And NO It does not reuse the cached "credentials". – Akin Okegbile Dec 04 '18 at 17:56
0

In your project root folder open .git/config. This file has details about remote url and your credentials type.

Your current remote url in this file might be storing credentials. Copy remote url from github and update the url in this config file.

Like below:

[remote "origin"]
    url = [update it]
    fetch = +refs/heads/*:refs/remotes/origin/*
[credential]
    helper = manager

Now when you try to push your code it will ask for credentials. Thanks

Mustkeem K
  • 5,524
  • 1
  • 24
  • 38
0

Answer for Mac Devices:

Go to

Applications/Utilities/Keychain Acccess

Search for git.credentials, and delete the git credentials for the desired URL.