How to resolve github git push command line authentication failed error?
1. Purpose
In this post, I would demo how to resolve the Authentication failed
error when doing git push
in command line.
2. Environment
- git version 2.24.3
3. The problem
When you type the following command in terminal:
You get this error message:
Why did this happen? It used to work!!!
4. The reason
Because github deprecates the password authentication from August 13, 2021. Now the PAT(Personal access token) is recommended for authenticaion in command line.
5. The solution
You can just do the following steps to solve this problem:
-
- Create you PAT (Personal access token)
-
- Update your local authentication token to the new token
5.1 Create your personal access token
You can just follow this document to create your pat. Just login github and click settings in your profile as follows:
Then click developer settings
:
And then choose Personal access tokens
:
You should grant the token with repo
permissions to do git checkout or push commands.
Then you should copy the token to your notes, write it down on a paper. It can not be seen again.
5.2 Delete the old token
You can reset the old password authentication token as follows:
You could also disable use of the Git credential cache using git config —global —unset credential. helper . Then reset this, and you would continue to have the cached credentials available for other repositories (if any). You may also need to do git config —system —unset credential.
5.3 Test again
Now we can test again:
6. Summary
In this post, I demonstrated how to solve the github personal access token issue .
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Token authentication requirements for Git operations
- 👨💻 GitHub - bswen/bswen-project: code for www.bswen.com
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!