Reset git credentials on a Mac

I tried doing a git push to my HTTPS GitHub remote, but received this error:

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/thomashalljr/thomas-hall-jr-blog.git/'

So I found out I needed to reset my git credentials using this command (note: after entering this multi-line command, you shouldn’t get any output and that’s okay).

git credential-osxkeychain erase
host=github.com
protocol=https

Then, the next time you git push, you should be prompted for your GitHub username and password. The username to enter was obvious, but GitHub no longer supports account passwords for authenticating things like command line usage.

Instead, they accept personal access tokens over HTTPS. Here is a GitHub Docs article about creating a personal access token to use as your password. After entering your personal access token as your password in the command line, the next git push should be good to go.

References

https://docs.github.com/en/get-started/getting-started-with-git/updating-credentials-from-the-macos-keychain#deleting-your-credentials-via-the-command-line

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/