Git 推送:缺少凭据或凭据无效.致命:“https://github.com/username/repo.git"的身份验证失败 [英] Git push: Missing or invalid credentials. fatal: Authentication failed for 'https://github.com/username/repo.git'

查看:177
本文介绍了Git 推送:缺少凭据或凭据无效.致命:“https://github.com/username/repo.git"的身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在新 MacBook 上进行第一次推送,但在 git push 后出现此错误(在我的旧 MacBook 上一切正常):

缺少或无效的凭据.错误:连接 ECONNREFUSED/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock在 PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {errno: 'ECONNREFUSED',代码:'ECONNREFUSED',系统调用:'连接',地址:'/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'}缺少凭据或凭据无效.错误:连接 ECONNREFUSED/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock在 PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {errno: 'ECONNREFUSED',代码:'ECONNREFUSED',系统调用:'连接',地址:'/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'}远程:没有匿名写访问权限.致命:https://github.com/username/repo.git/"的身份验证失败

知道为什么以及如何解决它吗?

解决方案

如 (git config --global credential.helper osxkeychain)

  • 从 OSX 更新凭据钥匙扣
  • 您将在此处输入您的实际凭据:

    • 您的 GitHub 用户帐户名
    • 您的 GitHub 用户帐户密码(或 PAT 如果您有 2FA 激活)

    但如果今天问题消失了,那么这就是与此 GitHub 事件相关.>


    Andreas L 还提到了 在评论中 尝试从集成的 VS Code 终端进行身份验证可能很棘手.
    git push origin master Missing or invalid credentials"和此处:

    <块引用>

    如果您使用 JSON-settings 文件,请将以下行插入其中:

    git.terminalAuthentication: false,

    I was trying to do my first push on a new MacBook and got this error after git push (everything worked well on my old MacBook):

    Missing or invalid credentials.
    Error: connect ECONNREFUSED /var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock
        at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'
    }
    Missing or invalid credentials.
    Error: connect ECONNREFUSED /var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock
        at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'
    }
    remote: No anonymous write access.
    fatal: Authentication failed for 'https://github.com/username/repo.git/'
    

    Any idea why and how I can resolve it?

    解决方案

    As mentioned in marpo-it's answer, the setting git.terminalAuthentication can be unchecked (since VSCode 1.45)

    That will avoid that, for Git commands invoked in the Integrated Terminal, like git push for instance, you would automatically be authenticated against your GitHub account.


    Original answer:

    I have set up credentials by using git config user.name "your username" and git config user.password "your password", and could see these by running git config --list, what am I missing here?

    Those are not "credentials": they won't help authenticate you to a remote service like GitHub.

    For HTTPS URLS (https://github.com/<me>/<myRepo>), you would need to:

    There you would enter your actual credentials:

    • your GitHub user account name
    • your GitHub user account password (or a PAT if you have 2FA activated)

    But if the issue disappear today, then this was linked to this GitHub incident.


    Andreas L also mentions in the comments that trying to authenticate from an integrated VS Code terminal can be tricky.
    As detailed in "git push origin master Missing or invalid credentials", and here:

    If you work with the JSON-settings file, insert the following line into it:

    git.terminalAuthentication: false,
    

    这篇关于Git 推送:缺少凭据或凭据无效.致命:“https://github.com/username/repo.git"的身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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