问题
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?
回答1:
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 manual detailing the Windows credential store panel:
Open User Accounts by clicking the Start button Picture of the Start button, clicking Control Panel, clicking User Accounts and Family Safety (or clicking User Accounts, if you are connected to a network domain), and then clicking User Accounts. In the left pane, click Manage your credentials.
回答2:
If this problem comes on a Windows machine, do the following.
- Go to Credential Manager
- Go to Windows Credentials
- Delete the entries under Generic Credentials
- Try connecting again. This time, it should prompt you for the correct username and password.
回答3:
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
回答4:
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.
回答5:
Try using the below command.
git credential-manager
Here you can get various options to manage your credentials (check the below screen).
Or you can even directly try this command:
git credential-manager uninstall
This will start prompting for passwords again on each server interaction request.
回答6:
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:
回答7:
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.
回答8:
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".
回答9:
In Windows 2003 Server with "wincred"*, none of the other answers helped me. I had to use cmdkey.
cmdkey /listlists all stored credentials.cmdkey /delete:Targetdeletes the credential with "Target" name.
(* By "wincred" I mean git config --global credential.helper wincred)
回答10:
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.
回答11:
Got same error when doing a 'git pull' and this is how I fixed it.
- Change repo to HTTPS
- Run command
git config --system --unset credential.helper - Run command
git config --system --add credential.helper manager - Test command
git pull - Enter credentials in the login window that pops up.
- Git pull completed successfully.
回答12:
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.
- Open Keychain Access
- Find github
- 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
回答13:
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.
回答14:
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
回答15:
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.
回答16:
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.
回答17:
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
回答18:
- Go to
C:\Users\<current-user> - check for
.git-credentialsfile - Delete content or modify as per your requirement
- Restart your terminal
回答19:
On Windows, at least, git remote show [remote-name] will work, e.g.
git remote show origin
回答20:
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.
回答21:
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 yell 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 Bitbucket 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 repo but I have to work across several and using different providers so may encounter this issue again.
回答22:
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.
- Go to Finder
- Go to Applications
- Go to Utilities Folder
- Open Keychain Access
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
回答23:
To clear Git Credentials Managers for Windows cache:
rm $env:LOCALAPPDATA\GitCredentialManager\tenant.cache
or
rm %LOCALAPPDATA%\GitCredentialManager\tenant.cache
回答24:
In our case, clearing the password in the user's .git-credentials file worked for us.
c:\users\[username]\.git-credentials
回答25:
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.
回答26:
If you are authenticated using your key pair, you can deleting or moving your private key, or stopping the key agent and trying.
回答27:
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.
回答28:
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.
来源:https://stackoverflow.com/questions/15381198/remove-credentials-from-git