Step 1: Unset existing credentials
Copy this into your terminal:
git config --global --unset credential.helper
git credential-osxkeychain erase
host=github.com
protocol=https
and hit 'Enter' twice to delete existing GitHub credentials (username and password) from your computer.
Recommended: if you were previously authenticating using a GitHub Personal Access Token (PAT) and want to update to a new one, invalidate any old one(s) by visiting https://github.com/settings/tokens and clicking 'Delete' or 'Revoke All' to ensure an old token can no longer be used.
Step 2
Generate a new access token: go to GitHub, click on your profile pic on the top right -> Settings -> Developer Settings -> Personal Access Tokens -> Tokens (classic) and create a new one (tip: if you're not sure what permissions to grant, just select full 'repos' permissions and nothing more - you can always create another token with more permissions later if required).
Step 3
Go into private repository and try to push/pull. GitHub will prompt you for your username (email or GitHub username) and password (the token you just generated).
git credential-osxkeychain erase
. – Ocotillo