githubtokenpersonal-access-token

Error with git push using new personal access token


I am unable to push to git after generating a new personal access token. I've looked around at similar questions but think that I may have a more fundamental misunderstanding of how this works.

I got an email saying passwords were being phased out, so I generate a token and could no longer push a repo I've been working on using my password. From the instructions it looked like I can use the token just like a password, but to no avail. This is what the error looks like:

enter image description here

where I have pasted my token when prompted for password. (I've blacked out my username.) I am on Windows 10 and having checked my credentials manager do not appear to have credentials stored for github at the moment.

My questions are:

  1. Ideas for immediate convenient fixes? I was seeing some suggestions about setting the remote-url, but a little concerned about doing this for every repo I have. I'd like to change my workflow minimally, if possible.

  2. I'm probably grossly misunderstanding the point of the token. What is the "correct" way to set up a workflow to github? (Including maybe big changes that might take me a weekend to set up correctly, in a few weeks from now, say.) Am I supposed to set up a 2FA? (Will this change my web login at all?) Why is this more secure than a password? I've currently not setup SSH or anything else, really.


Solution

  • I followed a similar workflow, generating a new token (in github.com/settings/tokens), and using it as password without issues.

    I just made sure:

    The resulting token should start with ghp_

    ghp_DUvWjre....(ghp_ followed by 36 alphanumerical chars)
    

    The OP Tommy Tang confirms in the comments:

    I didn't find a previous credential, so I just added a generic credential on the manager, and it works.


    punsoca adds in the comments:

    Originally, I only selected the 'repo' scope and I followed your tip and added the 'workflow', 'gist', and 'user' scopes.

    Speaking of 'user' scope, everyone should make sure their user.email git setting is set as well.
    When Git detects that you changed your Personal Acccess Token (PAT), it will prompt you for a new password - just use the newly generated PAT and it will work!