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 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 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:
- Go to https://github.com/settings/tokens (if you prefer navigating through the menu, that’s User -> Settings -> Developer Settings -> Personal Access Tokens)
- Click “Generate new token”
- 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.
- Click “Generate token”
- Now, back on your computer, in the directory where you keep the code, open the file called .git/config
- Make sure that the parameter url is set to something like “https://<your github user name>:<the token you just generated>@guthub.com/<the path to the repo you want to push into>.git. I.e. make sure that
- The protocol is “https”, not “ssh”. The PATs do not work with ssh
- The URL contains the user name under which you want to push the code
- The URL contains the token you just generated
- 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).