github-How to solve github git push command line authentication failed error?

1. Purpose

In this post, I would demo how to solve 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:

➜  bswen-project git:(master) git push

You get this error message:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see for more information.
fatal: Authentication failed for ''

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:

  • 1) Create you PAT (Personal access token)
  • 2) 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:

git config --global --unset credential.helper

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:

➜  bswen-project git:(master) git push     
Username for '': bswen
Password for 'https://[email protected]': 
Enumerating objects: 29, done.
Counting objects: 100% (29/29), done.
Delta compression using up to 8 threads
Compressing objects: 100% (18/18), done.
Writing objects: 100% (26/26), 4.25 KiB | 1.42 MiB/s, done.
Total 26 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 3 local objects.
   ae95887..13352d4  master -> master
➜  bswen-project git:(master)   

6. Summary

In this post, I demonstrated how to solve the github personal access token issue .