264

I'm currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7.

On setting up my environment, I told git-credentials to permanently remember my username and password.

I've recently updated my GitHub password via the website and I'm now no longer able to push/pull/fetch, etc.

How I would go about updating my password on git-credentials helper on Windows 7?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrew Thomson
  • 4,572
  • 3
  • 18
  • 15
  • 12
    Simple, use "git config --global credential.helper wincred" and enter userID and password; then this will be stored for you, next time you change your password, rerun above command. – Akshay Lokur Mar 06 '17 at 05:52
  • If all else fails, and you're using TortoiseGit, you might want to try an action via that. For example a pull or fetch using Tortoise will prompt for the password, which you can then update. This seems to then overwrite the Git Bash cache, and you can use bash once more. – Paul F. Wood Jun 28 '17 at 09:36
  • @AkshayLokur This does not work for me, I get a message: "error: cannot overwrite multiple values with a single value". – MarkusSchaber Feb 01 '21 at 13:11
  • In addition to the comment by @AkshayLokur I had to follow the top comment under [this question](https://stackoverflow.com/q/11693074/3642162) – ijuneja Feb 26 '21 at 06:27
  • Does this answer your question? [How do I update the password for Git?](https://stackoverflow.com/questions/20195304/how-do-i-update-the-password-for-git) – user202729 Jun 01 '22 at 02:54

13 Answers13

376

None of these answers ended up working for my Git credential issue. Here is what did work if anyone needs it (I'm using Git 1.9 on Windows 8.1).

To update your credentials, go to Control PanelCredential ManagerGeneric Credentials. Find the credentials related to your Git account and edit them to use the updated password.

Reference: How to update your Git credentials on Windows

Note that to use the Windows Credential Manager for Git you need to configure the credential helper like so:

git config --global credential.helper wincred

If you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):

git config --global credential.useHttpPath true
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
xgo
  • 3,960
  • 2
  • 14
  • 12
  • 24
    This should be the accepted answer if `git config --list` contains `credential.helper=wincred`. – M. F. Nov 15 '17 at 11:15
  • 7
    Worked for me - thank you - and learnt about Windows credential manager too. – rwalter Feb 14 '18 at 13:44
  • This. changing the password didn't work but I deleted the credentials and then git push asked for credentials again and it worked. – BiAiB May 02 '18 at 12:39
  • 3
    I think it works for window 8.1 and window 10 also. In my case: window 10 Pro, git 2.17 – Thinhbk Jun 07 '18 at 15:03
  • Thank you! This worked for me. I used to be able to re-submit my pull, fetch, or push and I would be prompted to enter my new password. For some reason that no longer works. Thanks for teaching me about the Credential Manager! – Chris Stahl Dec 10 '18 at 15:00
  • 3
    For anyone that (like me) removes the stored credentials hoping for another prompt, but the prompt doesn't show. From Credentials Manager, you can `ADD` a `Generic Credential` with an address of `git:http://yourserver:port/`. Http or Https is the same, the important bit is the `git:` at the start. – Alberto Chiesa Jan 02 '19 at 13:35
  • Many thanks for this post. Our bitbucket is not using HTTPS or SSH. After running the second command setting `useHttpPath` as true it stopped messaging Authentication failed. – Michal Jun 07 '19 at 09:36
  • THANK YOU. Updating in the Control Panel's credential manager did the trick! I put my login instead of personal access token, so needed to update. – TBirkulosis Oct 24 '19 at 14:48
  • Why the heck isn't it the default to use the full path? – Thomas Weller Jan 12 '20 at 11:03
  • This doesn't only work with `wincred` but also with the credential manager core that comes with recent git version. Therefore you can use `git config --global credential.helper manager-core` which also stores the credential in the above mentioned Windows Credential Manager (German: Anmeldeinformationsverwaltung). Tested with git 2.31.1. – AlbertM Jul 20 '21 at 17:39
  • "To update your credentials, go to Control Panel → Credential Manager → Generic Credentials." In Windows 10, there is an extra step: : Control Panel → Credential Manager → Windows Credentials → Generic Credentials. – user697473 Aug 13 '21 at 17:38
  • For non-English Windows systems, you might look for something akin to "references" instead of "credentials". Worked on Windows 7. (Translated: `Configuration screen > User accounts and parental control > Reference management`.) – Mew Aug 19 '21 at 16:39
126

On my first attempt to Git fetch after my password change, I was told that my username/password combination was invalid. This was correct as git-credential helper had cached my old values.

However, I attempted another git fetch after restarting my terminal/command-prompt and this time the credential helper prompted me to enter in my GitHub username and password.

I suspect the initial failed Git fetch request in combination with restarting my terminal/command-prompt resolved this for me.

I hope this answer helps anybody else in a similar position in the future!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrew Thomson
  • 4,572
  • 3
  • 18
  • 15
  • 4
    Just restart Git Bash, it will prompt a dialog to enter new username / password. – Quan Mar 30 '17 at 04:13
  • 4
    For the record, I was able to workaround this by doing another pull/fetch without restarting my Powershell session on Windows 7. Windows prompted me for my new creds on the second attempt. – codewario May 16 '17 at 13:19
  • restarting the console/app made "wincred" work for me. ( I had to restart my console and "Atom" and everything worked fine ) – low_rents Jul 16 '17 at 20:06
  • 4
    Entering any git command which requires credentials a second time seems to do this, not just `git fetch`, it also worked on a second `git clone`. – navigator_ Oct 09 '17 at 18:32
  • 1
    thank you very much! Every time I change my domain password, I have to remember how to update my credentials.Git fetch - It worked for me! – Alexander Brattsev Jan 15 '20 at 16:01
  • 1
    Yup, this was the one. – SoEzPz Aug 21 '20 at 23:23
99

If you are a Windows user, you may either remove or update your credentials in Credential Manager.

In Windows 10, go to the below path:

Control PanelAll Control Panel ItemsCredential Manager

Or search for "credential manager" in your "Search Windows" section in the Start menu.

Then from the Credential Manager, select "Windows Credentials".

Credential Manager will show many items including your outlook and GitHub repository under "Generic credentials"

You click on the drop down arrow on the right side of your Git: and it will show options to edit and remove. If you remove, the credential popup will come next time when you fetch or pull. Or you can directly edit the credentials there.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vins
  • 1,931
  • 16
  • 14
  • 3
    After trying other options only this one worked for me. I found info here: https://cmatskas.com/how-to-update-your-git-credentials-on-windows/ – neomib Dec 03 '18 at 10:19
  • 2
    Note: this control is NOT ACCESSIBLE THROUGH METRO UI "CONTROL PANEL"! You have to run `control.exe` manually to see this control. – AnrDaemon Jun 03 '19 at 12:13
  • This helped a lot! I didn't even know that this tools existed. – jaw Jun 19 '20 at 07:25
  • This helped a lot. – Arsman Ahmad Jun 30 '21 at 17:02
  • There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks. – Kamlesh Jan 30 '22 at 08:33
98

Solution using command line for Windows, Linux, and MacOS

If you have updated your GitHub password on the GitHub server, in the first attempt of the git fetch/pull/push command it generates the authentication failed message.

Execute the same git fetch/pull/push command a second time and it prompts for credentials (username and password). Enter the username and the new updated password of the GitHub server and login will be successful.

Even I had this problem, and I performed the above steps and done!!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Farooque
  • 3,616
  • 2
  • 29
  • 41
46

First find the version you are using with the Git command git --version. If you have a newer version than 1.7.10, then simply use this command:

git config --global credential.helper wincred

Then do the git fetch , then it prompts for the password update.

Now, it won't prompt for the password for multiple times in Git.

Sireesh Yarlagadda
  • 12,978
  • 3
  • 74
  • 76
  • 7
    This doesn not answer the question – disklosr Oct 05 '17 at 12:21
  • 2
    @disklosr Yes it does. It forces Git to prompt for the updated password the next time you perform a remote action. – Nilpo Aug 10 '18 at 23:32
  • 1
    @Nilpo What is a "remote action" then? Should not "git push origin xxx" be a remote action? It isn't doing it. instead I get remote: Invalid username or password. – RichMeister Nov 26 '18 at 20:20
  • 1
    It worked for me. After executing this command. Do "git fetch", you will be prompted for credentials, provide it. – Manjeet Feb 18 '19 at 03:21
  • 1
    Why `--global`? Don't I risk to get re-asked for all my repositories instead of just the one affected? – Thomas Weller Jan 12 '20 at 10:39
43

It seems to me that the answers here are outdated. For me using Git v2.15.0 issuing git credential reject like this did the job:

$ git credential reject
protocol=https
host=github.com
<Empty line here>

And then to set the new username & password:

$ git credential fill
protocol=https
host=github.com
<empty line here>

After this, if the credentials now work on the desired target host, we should use git credential approve -as mentioned in typical use of Git credentials (step 4)- to tell the credential helpers to mark the credentials as approved and reuse them in future connections.

atavio
  • 1,145
  • 13
  • 19
  • 1
    For me, doing the `git credential fill` part as-is, it generated automatically the old wrong password; I've had to set the new one manually with this command for it to work; anyway, thanks, this answer helped me with this problem! – Emerson Cardoso Feb 04 '19 at 12:44
  • 1
    Upvote to the top! How much wasted time reading outdated solutions. Actually Git Credential Manager is to blame here I think for having to go through pain when domain passswords are rotated. – Janis Veinbergs May 07 '19 at 08:32
  • 1
    after ```fill```, shouldn't we use ```approve```? – Bernardo Dal Corno May 22 '19 at 19:16
  • On my machine `git credential reject` never completes – Thomas Weller Jan 12 '20 at 10:41
  • @ThomasWeller you have to hit enter to leave an empty line there, then it completes. – atavio Jan 13 '20 at 09:32
  • You are welcome @DavidCallanan! It's funny, the answer is pretty buried under the other answers, but still helping some people. – atavio Apr 20 '20 at 12:40
  • You saved my life, bro – Hugo P Mar 12 '21 at 14:37
  • 1
    +1 for giving a git-based solution instead of a windows based one. I'm running linux and needed to switch from a password to a PAT and this was the only answer that worked. – Patrick vD Mar 16 '21 at 18:19
  • 1
    to clarify in case others are as ignorant as me: after verifying that the new credentials work, when you enter `git credential approve`, enter the same 2 lines again as the other calls to `git credential`: `protocol=https` followed by `host=github.com`. – David Burson Oct 19 '21 at 17:39
  • 1
    This answer is a bit unclear. It looks like one is editing a text file or something here. Just a heads up for everyone else: This is just multi-line CLI input. – Tyler V. May 02 '22 at 21:27
27

FWIW, I stumbled over this very same problem (and my boss too, so it got more intense).

The instant solution is to delete or fix your Git entries in the Windows Credential Manager. You may have a hard time finding it in your localized Windows version, but luckily you can start it from the good old Windows + R run dialog with control keymgr.dll or control /name Microsoft.CredentialManager (or rundll32.exe keymgr.dll, KRShowKeyMgr if you prefer the classic look). Or put this in a batch file for your colleagues: cmdkey /delete:git:http://your.git.server.company.com.

In Microsoft's Git Credential Manager this is a known issue that may be fixed as soon as early 2019 (so don't hold your breath).

Update (2020-09-30): GCM4W seems to be more or less abandoned (last release more than a year ago, only one commit to master since then named, I kid you not, "Recreate the scalable version of the GCM Logo"). But don't despair, with Microsoft now going Core, there is a shiny new project called GCM Core, which seems to handle password changes correctly. It can be installed standalone (should be activated automatically, otherwise activate e.g. with git config --system credential.helper manager-core) but is also included in the current Git for Windows 2.28.0. For more information about it, see this blog post.

Jakob
  • 630
  • 6
  • 11
  • 1
    Understanding the Windows Credential Manager by using the Control Panel UI is great but gets tiresome when you have to update on all machines. This single command is great since it accomplishes the same thing (removes the existing invalid credentials) which forces git to prompt for the credentials again the next time it needs them. On Windows Server 2016, command syntax to remove credential is slightly different: `cmdkey /delete:git:https://your.git.server.company.com` – Rudimentary Dec 06 '18 at 08:39
  • `/delete{:}` is the [official syntax](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmdkey), but I found that the shortcut `/del ` also works, at least in Windows 10 (1803). – Jakob Dec 07 '18 at 09:31
  • great idea for an alias! ```delpw = !cmdkey /delete:git:$(git remote get-url $1)```. Usage: ```git delpw origin``` (ps: /del didn't work here, Win 10 as well) – Bernardo Dal Corno May 22 '19 at 19:06
20

Working solution for Windows:

Control Panel > User Accounts > Credential Manager > Generic Credentials

enter image description here

Waqas Ahmed
  • 1,780
  • 1
  • 14
  • 15
  • This will only work if you are logged as the user whose credentials you want to change; if you run git bash as admin and you are not admin, or you are changing credentials for a different user, this method won't work for obvious reasons. – Jorge.V Oct 12 '20 at 09:30
  • 1
    For Windows 10 it is named: Control Panel > User Accounts > Manage your Credentials > Windows Credentials, search for the git credentials and edit – htafoya Dec 17 '20 at 21:55
  • There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks. – Kamlesh Jan 30 '22 at 08:33
7

Just cd in the directory where you have installed git-credential-winstore. If you don't know where, just run this in Git Bash:

cat ~/.gitconfig

It should print something looking like:

[credential]
    helper = !'C:\\ProgramFile\\GitCredStore\\git-credential-winstore.exe'

In this case, you repository is C:\ProgramFile\GitCredStore. Once you are inside this folder using Git Bash or the Windows command, just type:

git-credential-winstore.exe erase
host=github.com
protocol=https

Don't forget to press Enter twice after protocol=https.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Luc DUZAN
  • 1,299
  • 10
  • 18
7

None of the current solutions worked for me with git bash 2.26.2. This should work in any case if you are using the windows credential manager.

One issue is the windows credential manager runs for the logged user. In my case for example, I run git bash with right click, run as admin. Therefore, my stored credentials are in a credentials manager which I can't access with the windows GUI if I don't login to windows as admin.

To fix this:

  • Open a cmd as admin (or whatever user you run git bash with)
  • Go to windows/system32
  • Type cmdkey /list. Your old credentials should appear here, with a part that reads ...target:xxx...
  • Type cmdkey /delete:xxx, where xxx is the target from the previous line

It should confirm you that your credentials have been removed. Next time you do any operation in git bash that requires authentication, a popup will ask for your credentials.

Jorge.V
  • 1,329
  • 1
  • 13
  • 19
  • **Accessing Credential Manager** https://support.microsoft.com/en-us/windows/accessing-credential-manager-1b5c916a-6a16-889f-8581-fc16e8165ac0 – Niko Apr 14 '22 at 15:46
6

For Windows 10 it is:

Control Panel > User Accounts > Manage your Credentials > Windows Credentials, search for the git credentials and edit

htafoya
  • 18,261
  • 11
  • 80
  • 104
  • There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks. – Kamlesh Jan 30 '22 at 08:33
2

If you have reset your password, hence you are getting Auth failure error in the git bash command window. (it does not show popup where you could enter new password).

In the git bash cmd window enter following command:

$ git config --global credential.helper wincred

Some times it will show popup to enter the new password or Sometimes popup will be displayed when you are trying to do $git clone ..command

Barani r
  • 2,119
  • 1
  • 25
  • 24
0

If you keep getting "fatal: Authentication failed for "https://......git" and you are unable to update the password.

  1. $ git config --global credential.helper wincred
  2. git clone -b ..git
  3. Popup will be displayed for username password
  4. enter the new password
Barani r
  • 2,119
  • 1
  • 25
  • 24