How to update authentication token for a git remote?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Over Ancient Waters Looping
--
Chapters
00:00 How To Update Authentication Token For A Git Remote?
00:44 Answer 1 Score 20
01:52 Accepted Answer Score 8
02:49 Thank you
--
Full question
https://superuser.com/questions/1309196/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#commandline #git #gitlab
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Over Ancient Waters Looping
--
Chapters
00:00 How To Update Authentication Token For A Git Remote?
00:44 Answer 1 Score 20
01:52 Accepted Answer Score 8
02:49 Thank you
--
Full question
https://superuser.com/questions/1309196/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#commandline #git #gitlab
#avk47
ANSWER 1
Score 20
CMD
With cmdkey:
- Run
cmdkey /list
from the command line, and find your target. - To update the password, run
cmdkey /generic:$TARGET_NAME$ /user:$MYUSERNAME$ /pass
and enter your password when prompted.- For example:
cmdkey /generic:git:https://gitlab.com /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.
ACCEPTED ANSWER
Score 8
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 themanager
helper).Type in the following text:
protocol=https host=gitlab.com path=/myusername/repo.git
The main
git credential
tool also accepts a simpler version (but individual helpers do not):url=https://gitlab.com/myusername/repo.git
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 fill
orgit credential-manager get
to make sure the credentials cannot be retrieved anymore.