1
votes

I am trying to set up and use a GitHub personal access token.

I have followed https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token and have created the token.

I have looked at https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#switching-remote-urls-from-ssh-to-https and I can https URLs returned when I run git remote -v

When I try and push I get a GitHub login prompt.

I close that and get an OpenSSH prompt.

I close that and type in my username and get another OpenSSH prompt for my password.

I close that and put in my personal access token and that still doesn't work.

According to the first link I should just be prompted for a username and token. Is there something else I need to do? I'm on Windows.

When I try on Linux (Ubuntu) I just a username and password prompt and the token works.

1

1 Answers

1
votes

If you are on Windows (with the latest Git For Windows), and do see an HTTPS URL on git remote -v, then the prompt should not be an OpenSSH one.

Make sure your git config credential.helper is set to manager-core.

Then a git push should ask for your credentials, where you can use your token as password.


Or: the OP tschumann makes it work by removing the credential helper.

To make sure there is no credentials cached though, I prefer:

  • checking that C:\Program Files\Git\mingw64\libexec\git-core is in my %PATH%
  • double-check what is stored in the Windows Credential Manager

That is:

printf "host=github.com\nprotocol=https"|git-credential-manager get

If you see the wrong password, remove it with

printf "host=github.com\nprotocol=https"|git-credential-manager erase

Repeat the erase command until you see a popup (do not enter your credentials)

Then do a git push, and enter your credentials to store them.

The OP tschumann confirms in the comments:

git config --global core.askPass "" ended up fixing the issue