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?
To push the code to GitHub from Visual Studio Code, you will need to create a GitHub account and install the “Github Pull Requests and Issues” extension. Note: Before pushing the code from VS Code to GitHub, you need to ensure that all the files are in one folder, and you have to push your folder to Github.
The “fatal: Authentication failed” error message If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account.
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 https://[email protected]/your_user/your_project.git
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 [email protected]
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:
-C "[email protected]"
user.email
that you set as your Git identityYou can check that your SSH keys are valid by entering this in the terminal:
$ ssh -T [email protected]
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?.
Yahooo! 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.
CTRL+,
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:
After 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 [email protected]: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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With