How to Set Up GitHub Personal Access Token to Fix Deprecated Usr/Pass Authentication

After creating a repo on my GitHub web page today, I tried and failed to use Git push to transfer local fies onto the GitHub remote server (cloud). This was attempted with

$ git push -u origin main

The error notice was: "error: unable to read askpass response from 'C:/Program Files/Git/mingw64/bin/git-askpass.exe'. This came as no surprise, as I was aware that pass/usr authentication was deprecated on 13th August 2021, and I had seen this before.

I had been using SSH keys with Git, and it had worked up to the thirteenth of August, but the way I had it configured on Windows 8, it was asking me to insert a Username and password (in a horrible pop-up box!) every time I did certain operations.

A few weeks ago, I started to look into this but, as a newbie to all this, I was a bit overwhelmed. The thing that got me was that I had failed to set up the SSH keys in such a way that they just worked, in the background, doing their stuff, like they were supposed to. And I wanted to be able to set them up right so that I could follow along with an online course I am doing. I had deleted SSH keys locally and on GitHub, and had created new ones but I still had the usr/pass dialog box problem. So I left it a couple of weeks.

Today, I came back and a quick search on the internet brought me to: ittwist.com/blog/github-personal-access-token which showed me this line:

git remote set-url origin https://YOUR_TOKEN@github.com/USERNAME/REPO.git

and this was the solution to my problem, though the article was not very clear to me.

All I had to do was plug in my token where it says YOUR_TOKEN, and I got this from GitHub after following ittwist.com's instructions, thanks. Then I put my GitHub identity in place of USERNAME, followed by the name of the repo I had created on GitHub. Paste that into Git. Enter. Git seems to have accepted it, as it gave me no feedback.

Now to retry

$ git push -u origin main

and IT WORKED! I checked my GitHub page and the files have been transferred. So now it looks like I can go ahead with the course on amigoscode.com that I was following.

The moral of the story is when you hit a problem: stay calm, take time off, believe you can do it with online help, try stuff even if it's not 100% clear why you are doing it, then think about why it worked. Oh, and tell yourself that at least you know what SSH keys are, and what a personal access token is AND that you know something about setting them up.

Now all I need is a clever mate to talk about this stuff with over beers. I am SURE that would help.