Git push : Missing or invalid credentials.致命: 'https://github.com/username/repo.git'身份验证失败

标签 git github visual-studio-code

我试图在新的MacBook上进行首次尝试,并在git push后收到此错误(在我的旧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/'
知道为什么以及如何解决吗?

最佳答案

marpo-itanswer中所述,可以不选中设置git.terminalAuthentication(since VSCode 1.45)

这样可以避免这种情况,对于在集成终端中调用的Git命令(例如git push),您将自动根据GitHub帐户进行身份验证。

原始答案:

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?


这些不是“凭证”:它们不会帮助您通过GitHub之类的远程服务进行身份验证。
对于HTTPS URLS(https://github.com/<me>/<myRepo>),您需要:
  • use a credential helper(git config --global credential.helper osxkeychain)
  • update the credentials from the OSX Keychain

  • 在此输入您的实际凭证:
  • 您的GitHub用户帐户名称
  • 您的GitHub用户帐户密码(如果您有PAT,则为2FA activated)

  • 但是,如果问题今天消失了,那就是linked to this GitHub incident

    Andreas L还提到in the comments,尝试从集成的VS Code终端进行身份验证可能很棘手。
    git push origin master Missing or invalid credentialshere中所述:

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

    git.terminalAuthentication: false,
    

    关于Git push : Missing or invalid credentials.致命: 'https://github.com/username/repo.git'身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62860280/

    相关文章:

    git - 如何恢复已删除的 .git/modules 文件夹

    Github api 用于获取对给定存储库分支完成的所有提交

    visual-studio-code - 在 Visual Studio Code 中设置 isDevelopment 时

    java - 无法从 eclipse neon 推送到 bitbucket

    git - `git merge -s theirs` 需要但不存在

    git - 没有这样的文件或目录 - 运行 git add 时

    visual-studio-code - 转到 .jsx 的定义不起作用

    github - 缩进不适用于 EditorConfig Sublime Text 3

    git - Git 中如何小心地推送到新的分支

    visual-studio-code - (S) 被按下。等待和弦的第二个键