Can I update the token of a cloned repo?

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 ?

Hi @aleks-ivanov, personal access tokens are associated with user accounts not your repository.
If you have not rẻ-entered your new PAT ata prinoy then most likely you are using a Git client where you Credential is cached.
You can safely delete your old cached Credential, if this is the case and you should get prompted to enter a new one in tbe next authenticated git command

For Windows example see here…

I never use cached credentials, I always use per cloned repo authentication like this:

git clone

That doesn’t look like one of the current PATs (which should start with ghp_). However, if that is an old token, you should revoke it now after sharing it on a public forum. :warning:

Not an actual token of course, just a random smash of the keyboard as example

If your token is entered correctly but still not working you coul check it has the correct repo scope enabled.
I don’t personally specify in git like you are doing here but have you tried format

The solution to my original problem is the following:

$newGitHubPAT = "ghp_..."
$newOrigin = "https://token:$"
git remote remove origin # origin is the remote repo
git remote add origin $newOrigin

Basically you just remove the old origin that referenced the remote repository with the old token and add the origin with the new PAT.

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.

I agree, but it is really convenient :slightly_smiling_face: