Like me, you may have received the above notice (text below) after a recent push to your GitHub repo:
Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.
I found the official docs a bit confusing, so after some digging, I found the following steps to be the easiest way to update your GitHub git remote from password to personal access token authentication:
Step-by-Step Guide to Changing your GitHub Remote Authentication from Password to Personal Access Token
- Go to https://github.com/settings/tokens and Log In
- Click “Generate new token”, and then confirm your password
3. Add a token name (you can use a naming convention to help keep track of who has which token if you like) and select your desired scopes/permissions. Basic repo read/write access can be achieved by simply checking the repo box (see below).
4. Scroll down and click “Generate token”.
5. Copy the token itself by clicking the blue clipboard. Keep this private! Do not share this token with anyone you don’t want to have access to your repo (I have included the full token in this example for demonstration purposes but I deleted it afterward).
6. Now change your remote locally. Fire up your local terminal and
cd into your local repo directory. Note: if you need to remove the old remote do so now; for example, run a
git remote remove origin to remove the
7. Add your new remote in the following format:
git remote add origin https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
8. Now run
git remote -v and you should see something like this:
That’s it! Now try pushing a test commit to ensuring everything is working correctly, and the GitHub warnings should stop.
If you found this helpful, please consider following me on Twitter @elitwilliams for similar content.