# Git "remote: Invalid username or password" in CI

> Fix Git "remote: Invalid username or password" over HTTPS in CI - a wrong/empty credential, a password where a token is required, or a mismatched username/token pair.

Source: https://latchkey.dev/learn/git/git-remote-invalid-username-or-password  
Updated: 2026-06-25

The host rejected the HTTPS credential as invalid. The connection reached the server, but the username/password (or token) pair was wrong, empty, or used a password where a token is required.

## Diagnose it: depth, refs, or credentials?

```Terminal
git rev-parse --is-shallow-repository
git rev-parse --abbrev-ref HEAD    # prints HEAD when detached
git log --oneline -3
git remote -v
```

> `actions/checkout` fetches depth 1 on a detached HEAD. Anything diffing against a base, reading a branch name, or running `git describe` needs `fetch-depth: 0`.

## FAQ

### What causes Git "remote: invalid username or password" in CI?

There are 3 common causes: a password supplied where a token is required, empty or malformed credential, and mismatched username/token pair. GitHub does not accept account passwords for Git over HTTPS.

### How do I fix Git "remote: invalid username or password" in CI?

There are 2 fixes depending on which cause you have: use the correct username/token pairing and confirm the secret actually resolved. Work through them in order, since the first is the most common.

### What does Git "remote: invalid username or password" in CI actually mean?

A clone/fetch/push over HTTPS fails with remote: Invalid username or password followed by fatal: Authentication failed.

### How do I stop Git "remote: invalid username or password" in CI happening again?

Never use account passwords for Git automation - use tokens or SSH. The prevention section lists 3 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
