1

I am having the below error when pushing code to github

remote: No anonymous write access.fatal: Authentication failed for 'https://github.com/username/repo.git/'

Tried resolving by doing the following by doesnt resolve the issue

  1. setting origin to https://personalAccessCode@github.com/username/repo.git --> prompt to login using browser login, code, token --> tried all and all didnt work
  2. setting origin to https://username:personalAccessCode@github.com/username/repo.git --> prompt above error when push

Anyone have encounter this on VS 2022 community edition?

Xiaoxin
  • 23
  • 4

2 Answers2

1

Thank all for your help. I managed to successfully push code to git after removing a global settings that set the PAT access token which I use it to connect Azure DevOps

git config --global http.extraHeader

Xiaoxin
  • 23
  • 4
0

First, the URL should not include your token (you can include your GitHub user account name).

Second, VS2022 has an integration with a Git credential helper: check if your is set to GCM (or GCM Core, even though GCM Core has been replaced by GCM).

Both GCM or GCM core are packages with the latest Git for Windows, so make sure to use the latest one.

Below is the result I have got after changing URL and credential-helper as suggested. But still having the same error

enter image description here

enter image description here

Xiaoxin
  • 23
  • 4
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • After changing url to exclude token and account name and setting Git credential helper to GCM code. Retry pushing code up to remote and below the error I have. I was prompt to enter my personal token – Xiaoxin Feb 06 '23 at 14:03
  • @Xiaoxin Yes, it should prompt you to enter your token. And then it should store it, and not ask for it again. – VonC Feb 06 '23 at 20:15
  • Currently still having "Remote: No write access. fatal: Authentication failed for" error after keying the personal token – Xiaoxin Feb 08 '23 at 01:16
  • @Xiaoxin Can you check if the token is correctly registered with: `printf "host=github.com\nprotocol=https\nusername=yourLogin` | git credential-manager get` (replace `yourLogin` with your GitHub user account) – VonC Feb 08 '23 at 09:26
  • I got an error saying "Missing 'protocol' input argument" after running the above command – Xiaoxin Feb 09 '23 at 14:44
  • @Xiaoxin I missed a double quotes. Let me try that again: `printf "host=github.com\nprotocol=https\nusername=yourLogin" | git credential-manager get` – VonC Feb 09 '23 at 15:00