How to Push Your Code to GitHub Using Personal Access Token (PAT)

Photo by Roman Synkevych on Unsplash

Imagine the frustration when you edited your code hosted on GitHub as usual, did “git commit” as usual, did “git push” as usual, and instead of usual output you see something like

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 '<your beloved repo>'

Don’t be too frustrated, that’s all done for the sake of security, even though GitHub doesn’t provide clear and simple instructions of what to do next. The hackers would be just as frustrated as you are for sure :) Anyway, here is a quick way to fix this:

  1. Go to (if you prefer navigating through the menu, that’s User -> Settings -> Developer Settings -> Personal Access Tokens)
  2. Click “Generate new token”
  3. Select the scopes. The scope you need is called “repo”, so make sure to check that. If you plan to do something else with the token, you can check other boxes as needed too, but just for “git push” to work that “repo” scope would be sufficient.
  4. Click “Generate token”
  5. Now, back on your computer, in the directory where you keep the code, open the file called .git/config
  6. Make sure that the parameter url is set to something like “https://<your github user name>:<the token you just generated><the path to the repo you want to push into>.git. I.e. make sure that
    1. The protocol is “https”, not “ssh”. The PATs do not work with ssh
    2. The URL contains the user name under which you want to push the code
    3. The URL contains the token you just generated
  7. Once you updated your .git/config, you can run “git push” again and this time it should work (that’s until Github implement something new, very secure and not very well explained).

Leave a Reply