来自VS Code的git push:“没有匿名写访问权限.验证失败" [英] git push from VS Code: "No anonymous write access. Authentication failed"

查看:170
本文介绍了来自VS Code的git push:“没有匿名写访问权限.验证失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注Github本身的教程.我正在遵循的一个教您从Visual Studio Code开始工作的人.

我试图从Visual Studio Code中推送某些内容,一段时间后,出现以下错误:

  remote:没有匿名写访问权限.致命:.身份验证失败. 

现在,我正在向我的个人帐户推送内容.我试图用谷歌搜索(但是我还是一个新手,所以我并不完全理解所有术语),我能找到的是2FA(但是在我看来是不对的)和Windows凭据的问题(但是我检查了一下,然后我Windows凭据中没有任何git.)

所以我很茫然.有人知道我可以尝试/检查的其他东西吗?

解决方案

VS代码在提交并推送到远程仓库时仅使用环境的git配置.因此,在担心VS Code之前,您必须首先确保为Git正确设置了本地环境.

第一,我建议您先阅读

  • 在VS Code中,请确保使用相同的 git@github.com:..... URL
  • 我的Windows凭据中没有任何git

    您可以选择完全禁用它,因为我发现Windows凭据管理器可能会导致问题,并且使用SSH更稳定".请参见如何为Windows禁用Git Credential Manager?.

    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 2FA (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. Does anyone know something else that I could try/check?

    解决方案

    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 johndoe@example.com
    

    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:

    1. Generate a SSH key on your machine (Generating a new SSH key)
      • There's a step there that specifies -C "your_email@example.com"
      • Make sure that it matches the git user.email that you set as your Git identity
    2. 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 git@github.com
    Hi ginomempin! You've successfully authenticated, but GitHub does not provide shell access.
    

    Now,

    1. Clone your repo
      • Make sure to select the Clone with SSH option in Github
    2. In VS Code, make sure to use that same git@github.com:..... URL

    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?.

    这篇关于来自VS Code的git push:“没有匿名写访问权限.验证失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆