Skip to content

git push asks for a password or uses the wrong account

Username for 'https://github.com':

Git is asking you to sign in, because no sign-in helper answered. Or the push went through, but as the wrong GitHub account.

  • The GitHub account is not signed in to gh. Devpit’s helper asks gh for the account’s token. If that account is signed out in gh, there is nothing to give Git, and Git asks you.
  • The remote is SSH, not HTTPS. A remote like git@github.com:you/repo.git uses your SSH key, and the account that key belongs to. Devpit’s helper is not used.
  • The repository has its own helper. A credential.helper set inside the repository comes first. Devpit shows it as “this repo’s own sign-in helper”.
  • Lines after Devpit’s block in your ~/.gitconfig can win over its rules. Verify tells you which file wins.
  • A variable is set. GH_TOKEN or GITHUB_TOKEN in the terminal make gh use that token.
  • Devpit was uninstalled without cleanup. The helper line in Devpit’s rules file still points at a devpit.exe that is gone.
  1. In the repository folder, run devpit accounts verify, which checks which GitHub account a push will use. In the app, the Pushes as row of the Git page says what decides it here: Devpit’s sign-in helper, Git’s own helper, this repo’s own helper, or the SSH key.
  2. If the GitHub account is signed out, sign it in again with gh auth login, then check gh auth status lists it.
  3. Check the remote: git remote -v. For an SSH remote, give the folder its own key, see SSH remotes.
  4. Check the repository’s own helper: git config --local --get-all credential.helper.
  5. For one push as another account: devpit github run work -- git push.
  6. If you removed Devpit, reinstall it and run devpit accounts cleanup, or delete the [include] block that names rules.gitconfig at the end of your ~/.gitconfig.

Never paste a token into a terminal or a file to make a push work. Sign in through gh and let the helper pass it.

Common questions

Does GitHub accept my account password for git push?

No. GitHub does not accept account passwords for Git over HTTPS. Git needs a token from a sign-in helper such as gh, Git Credential Manager or Devpit's helper, or an SSH key.

Which GitHub account does a push use?

Over HTTPS, the account the sign-in helper answers with. Over SSH, the account the SSH key belongs to. The Pushes as row on Devpit's Git page says which one decides in the folder.