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
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.
In our case, clearing the password in the user's .git-credentials file worked for us.
c:\users\[username]\.git-credentials
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 Panel → User Accounts → Credential Manager → 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.
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:
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".
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.(* By "wincred" I mean git config --global credential.helper wincred
)