gitgithubvisual-studio-code

Git push: Missing or invalid credentials. fatal: Authentication failed for 'https://github.com/username/repo.git'


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?


Solution

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

    setting

    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:

    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,