git remote上的身份验证失败

joa*_*kim 22 visual-studio-code

我正试图从VSCode向我的Github存储库推送,拉取任何东西.
我输入了我的用户名和密码,但我收到的错误是Authentication failed on the git remote.
我刚刚使用相同的用户/通行证登录github.com.
我尝试创建个人访问令牌,使用它作为密码,同样的错误.

ale*_*jjj 87

我相信我已经找到了解决这个问题的方法。上述解决方案都不适合我。我认为这个问题的根本原因是GitHub已于2021年8月13日结束了对密码身份验证的支持。而是需要使用个人访问令牌。

解决该问题的步骤如下:

  1. 在 GitHub.com 上创建个人访问令牌。教程在这里
  2. 返回 Visual Studio Code 并打开终端。输入以下命令以及您自己的用户信息:
git remote set-url origin https://<TOKEN>@github.com/<user_name or organization_name>/<repo_name>.git
Run Code Online (Sandbox Code Playgroud)

如果您想遵循视频指南,这个视频会非常有帮助。


joa*_*kim 33

通过在Git中缓存GitHub密码来解决它.

步骤如下:

  1. 下载并安装Git for Windows
  2. 运行Git Bash,cd到repo dir并输入 git config --global credential.helper wincred

  • 修复了我无法提交私人仓库的问题. (2认同)

Uda*_*day 5

在 GitHub 于 2021 年 8 月 13 日更改其政策以使用个人访问令牌 (PAT) 而不是密码进行身份验证后,我就遇到了这种情况。

\n

我为自己做了这些步骤。我使用的是Lubuntu 20.04。

\n
    \n
  1. 在我的主目录中创建.gitconfig并添加以下内容

    \n
    [user]\n   name = {your github username}\n   email = {your email}\n[credential]\n   helper = store --file ~/.git-credentials\n
    Run Code Online (Sandbox Code Playgroud)\n
  2. \n
  3. 在我的主目录中创建,.git-credentials如上所示,并添加以下内容

    \n
    https://{your github username}:{your github PAT}@github.com\n
    Run Code Online (Sandbox Code Playgroud)\n
  4. \n
  5. 最后一步:重新启动终端并瞧\xc3\xa0!尝试在现有的 Visual Studio Code Git 文件夹中提交/推/拉,一切都会像以前一样工作。

    \n
  6. \n
\n

安全问题

\n

您的个人访问令牌 (PAT) 将以清晰的 ASCII 文本形式公开,如果任何人有权访问您的用户帐户,则可以读取。

\n