I was following a tutorial from GitHub itself. I am following the one that teaches you to work from Visual Studio Code.
I was trying to push something from Visual Studio Code and after quite some time I get the following error:
remote: No anonymous write access. fatal: Authentication failed for .... Now I am pushing something to my personal account. I tried to google (but again I am new to this so I don't fully understand all the terminology) and what I could find are issues with two-factor authentication (but that is off in my case) and Windows credentials (but I checked and I do not have any Git in my Windows credentials).
So I am at a loss. What else I could try or check?
47 Answers
A simpler method is to use personal access tokens at GitHub. This feature can be set up by going to your GitHub account → Settings → Developer settings → Personal access tokens → Generate a personal access token. Make your access control selections, generate, then copy and save your new token. After this, go to your Git project directory and this enter in the terminal:
git remote set-url origin
From now on you can easily do git push from the terminal or Visual Studio Code.
VS Code just uses your environment's git configuration when it commits and pushes to the remote repo. So, you'll have to first make sure that your local env is set up correctly for Git, before worrying about VS Code.
1st, I recommend going through the First-Time Git Setup from the Git docs. The most important part there is setting-up your Git identity:
$ git config --global user.name "John Doe" $ git config --global user.email 2nd, I recommend setting-up SSH keys on your local machine and on your GitHub profile. GitHub has an entire tutorial on Connecting to GitHub with SSH.
Basically:
- Generate a SSH key on your machine (Generating a new SSH key)
- There's a step there that specifies
-C "" - Make sure that it matches the git
user.emailthat you set as your Git identity
- There's a step there that specifies
- Add that SSH key to your GitHub account, in the SSH and GPG keys section.
You can check that your SSH keys are valid by entering this in the terminal:
$ ssh -T Hi ginomempin! You've successfully authenticated, but GitHub does not provide shell access. Now,
I do not have any Git in my Windows credentials
You can choose to disable that entirely, as I find that the Windows credentials manager can cause problems, and using SSH is more "stable". See How do I disable Git Credential Manager for Windows?.
8Yahooo! Finally, an Issue resolved
This is only for those who are facing this issue from the last update of VS Code. (NOV 15, 2021 or around)
The issue on Github Community #LINK
No need to downgrade VS Code, or git version. basically what I understood from the fix that worked for me. think it's a sort of conflict between GitHub and Git authentication.
So there are a few steps you can try and hopefully, it would be fixed for you too.
Open your Settings In VS CODE.
- Open settings from the left bottom corner (Settings icon) or press
CTRL+, - type Authentication in the search option, it will show something like this.

- You need to uncheck Git: Terminal Authentication. (e.g)

- Only Github: Github Authentication should be checked.
Now you need to close the opened terminal (if any). open your new terminal and try with git commands. 
on my end, everything is working fine. hope this works for you too. :slight_smile:
4After setting up the SSH key, you need to type this in your IDE (I'm using Visual Studio Code)
git remote -v This will show you your current remote branch URL, but you can no longer use that.
To update it, type this in your console
git remote set-url origin :YOURUSERNAME/reponame.git Now try to push or make any changes
NOTE: From my perspective I think you'll have to perform this operation for all your existing (old) repositories too.
1Try to go through the terminal with sudo git push. If you have two-factor verification, use the token instead of the password like this:
Username for ' <username>
Password for ' <token>
1You need to go back to the old version of Visual Studio Code and everything will be fine and all problems will be solved. It seems that the problem is in the latest version of Visual Studio Code and I hope it will be fixed. I am using Linux, an Ubuntu distribution.
What I have learn is that, You cloned the repository into an ssh terminal in vs-code. The first thing you could have done is to use gitbash terminal, it usually has this sign ">" as against the bash terminal which has a cube-like sign.
So before you clone a repository make sure you are using a gitbash terminal, hence, why the problem. Here is what I did. So since you used bash we have to play with "ssh".
First step, write this command in the repository you cloned
$ git config --global user.name "username in github" $ git config --global user.email "email used in gihub" Second Step
When you get to this step below in the document, continue below;
Step 2 Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519 Instead of typing this command: $ ssh-add ~/.ssh/id_ed25519
Use this: ssh-add,
It will prompt you to enter paraphrase or something. type it.
Then make sure you have added the ssh key successfully by running this code:
ls -al ~/.ssh try and cd to the directory of ssh
You should see something like this :
-rw--- 1 barry barry 465 Nov 1 07:47 id_ed23333 -rw-- 1 jospeh jose 115 Nov 1 09:47 id_ed23333.pub try and run this command:
cat id_ed23333.pub It will give you; your ssh key copy it and go to your github account. After this go to your repository click on "code" you should see http /ssh click on "ssh', it should show you if you need to add an ssh key click on add key, name the key anything you want and paste the key you copied then add key.
Go back to vscode and rerun the usually code.
git add . git commit -m "message" git push