Skip to content

Instantly share code, notes, and snippets.

@vi4hu
Last active June 3, 2023 18:25
Show Gist options
  • Save vi4hu/5eb544812d7665592f126d390092a59c to your computer and use it in GitHub Desktop.
Save vi4hu/5eb544812d7665592f126d390092a59c to your computer and use it in GitHub Desktop.
How to reset you github Personal Acess Token (PAT) in linux terminal

if you are doing first time with this method

The most simple and working solution i was able to find is removing the config file itself, git will generate it again so its fast and simple.

don't push till the very end.

rm ~/.gitconfig

Note: after doing this git will forget about your username and email so, run this command.

git will prompt this on your first fresh commit anyway, but don't forget to do this. the relation between you signed commit(via email) to account is very important.

git config --global --edit

Fill the info and you are good to go. Looks something like this.

# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = yourusername
email = your@mail.com

Now use cache to store the username and PAT(password) so you don't have to type it again and again on every push

git config --global credential.helper 'cache --timeout=3600'  # 7776000 for 9 month

Try pushing now!

When updating

git config --global --unset credential.helper
# try pulling/pushing, enter username and PAT when prompted. Then,
git config --global credential.helper 'cache --timeout=3600'  # 7776000 for 9 month

This is it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment