I revoked my token for GitLab, how can I set the new token for cmd use?
When trying to push, this is the error I get:
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'The credential.helper is set to manager.
I tried to unset credential.helper, and then when I push it asked for the credentials, which will work when I supply them. If I re-set credential.helper to manager, it will raise the previous error again.
So, how can I set the new token?
(The preferred method would be from the cmd).
Thanks!
2 Answers
Here's a generic method that should work with all currently configured (and writable) credential helpers (and to be honest, I'm surprised git didn't do this automatically – it's supposed to):
Run
git credential reject(to use all configured helpers) orgit credential-manager erase(to use themanagerhelper).Type in the following text:
protocol=https host=gitlab.com path=/myusername/repo.gitThe main
git credentialtool also accepts a simpler version (but individual helpers do not):url=At a blank line, press Ctrl+Z, Enter (Windows Console) or Ctrl+D (Linux, Cygwin, macOS...) to signal end-of-input.
If you want, repeat with
git credential fillorgit credential-manager getto make sure the credentials cannot be retrieved anymore.
CMD
With cmdkey:
- Run
cmdkey /listfrom the command line, and find your target. - To update the password, run
cmdkey /generic:$TARGET_NAME$ /user:$MYUSERNAME$ /passand enter your password when prompted.- For example:
cmdkey /generic:git: /user:myusername /pass
- For example:
- Use the credential again - push to your git remote.
GUI
With Windows Credential Manager:
- From the start menu, search and open the Credential Manager.
- Or, run
control /name Microsoft.CredentialManager
- Or, run
- Go to the Windows Credentials section and find your relevant credential (e.g the git remote service, in this case - GitLab).
- Open the credentials details.
- Choose Edit
- Enter the new password.
- Save.
- Use the credential again - push to your git remote.