Reputation: 3459
I had to revoke the old Github token for a private repo.
Now generated a new token from Github.
How to add this old token to the existing repo?
Without updating this new token push/pull is failing:
git push origin master
remote: Invalid username or password.
fatal: Authentication failed for....
I know how to solve this problem if I can re-clone the repo. However, I want to avoid cloning the repo again.
Upvotes: 3
Views: 3165
Reputation: 11
You could also do it in one line. Had the same problem. This worked for me:
git remote set-url origin https://<USER>:<TOKEN>@github.com/<USER>/<REPO>.git
Upvotes: 1
Reputation: 3459
I have to edit the .git/config
and update the URL with the user correct token.
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://<user>:<token-id>@github.com/user/repo.git
Here token-id
is set to the updated one.
Upvotes: 4
Reputation: 605
GitHub tokens actually exist at an account level and not a repo level.
See these instructions on how to add a token to your account: https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account
Upvotes: -1