Can I update the token of a cloned repo? #22434
-
A long while back I cloned a repo I own with a PAT. Recently, since the GitHub PAT algorithm update, I changed my PATs, so now the cloned repo can’t auth properly and therefor I can’t push to origin. Is there a way to update the token of the cloned repo, so I don’t have to remove the local clone and clone it all over again ? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 9 replies
-
Hi @aleks-ivanov, personal access tokens are associated with user accounts not your repository. For Windows example see here…
If you are still using an existing cached password for you login you will need to remove it, the below will help, hopefully slight_smile Launch ‘Credential Manager’ on your Windows device. Switch to tab Windows Credentials (it default displayed tab Web Credentials on my device). A list of locally cached credentials are then shown Find an entry starting something like git:htttps//[email protected] (this will be an exist cached entry for your username/password. You can safely delete this by … |
Beta Was this translation helpful? Give feedback.
-
I never use cached credentials, I always use per cloned repo authentication like this:
|
Beta Was this translation helpful? Give feedback.
-
That doesn’t look like one of the current PATs (which should start with |
Beta Was this translation helpful? Give feedback.
-
Not an actual token of course, just a random smash of the keyboard as example |
Beta Was this translation helpful? Give feedback.
-
If your token is entered correctly but still not working you coul check it has the correct repo scope enabled. |
Beta Was this translation helpful? Give feedback.
-
The solution to my original problem is the following:
Basically you just remove the old origin that referenced the remote repository with the old token and add the origin with the new PAT. |
Beta Was this translation helpful? Give feedback.
-
This works, but is potentially dangerous because the token ends up stored on your disk unencrypted. Anyone with access to the filesystem could copy it. |
Beta Was this translation helpful? Give feedback.
-
I agree, but it is really convenient 🙂 |
Beta Was this translation helpful? Give feedback.
-
hello. am not answering your question but asking my own. i cloned a repo using a pat a while back but the pat expired. i generated a new pat but every time i try to push to that repo, i am asked for my password. it is very annoying to copy and paste the pat every time i want to push my work to git. how do i deal with this please. id like to be able to push my work as efficiently as i did before. |
Beta Was this translation helpful? Give feedback.
-
We can avoid exposing the PAT by removing and adding back the remote.
Then when we try to push we are asked for username and password like the first time, and we can paste the PAT as the password, keeping it safe. |
Beta Was this translation helpful? Give feedback.
The solution to my original problem is the following:
Basically you just remove the old origin that referenced the remote repository with the old token and add the origin with the new PAT.