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

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

问题描述

我正在尝试在新MacBook上进行首次推送,并在 git push 之后收到此错误(在我的旧MacBook上一切正常):

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

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

解决方案

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

  • 从OSX钥匙串
  • 您将在其中输入实际凭据:

    • 您的GitHub用户帐户名
    • 您的GitHub用户帐户密码(或与此GitHub事件链接./p>

      Andreas L 还提到了 git push origin master 缺少或无效的凭证"和此处:

      如果使用JSON设置文件,请在其中插入以下行:

        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 push:缺少凭证或凭证无效.致命:"https://github.com/username/repo.git"的身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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