Skip to content
LatchkeyLatchkey home

Git "could not read Username" with no terminal in CI

Git had no credential to use and tried to prompt for one, but CI has no interactive terminal, so the read fails immediately. The real problem is that no token or helper was configured.

What this error means

A clone, fetch, or submodule update fails with fatal: could not read Username for the HTTPS remote: No such device or address. It never hangs; it errors at once.

git
fatal: could not read Username for 'https://github.com': No such device or address

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

Common causes

No credential configured for HTTPS

No token in the URL, no credential helper, and no stored credential, so Git falls back to an interactive prompt that cannot run.

Submodule URL without credentials

A submodule references an HTTPS URL that has no token, even when the parent clone was authenticated.

How to fix it

Provide a non-interactive credential

  1. Inject a token into the clone URL or configure a credential helper.
  2. Disable interactive prompting so failures surface clearly rather than hanging.
.github/workflows/ci.yml
export GIT_TERMINAL_PROMPT=0
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/org/repo.git

Rewrite auth for all github.com URLs

  1. Use an insteadOf rewrite so submodules and nested URLs inherit credentials.
Terminal
git config --global url."https://x-access-token:${GH_PAT}@github.com/".insteadOf "https://github.com/"

How to prevent it

  • Always configure an explicit token or credential helper for HTTPS Git in CI, and set GIT_TERMINAL_PROMPT=0 so missing credentials fail fast instead of stalling.

Frequently asked questions

What causes Git "could not read Username" with no terminal in CI?
There are 2 common causes: no credential configured for https and submodule url without credentials. No token in the URL, no credential helper, and no stored credential, so Git falls back to an interactive prompt that cannot run.
How do I fix Git "could not read Username" with no terminal in CI?
There are 2 fixes depending on which cause you have: provide a non-interactive credential and rewrite auth for all github.com urls. Work through them in order, since the first is the most common.
What does Git "could not read Username" with no terminal in CI actually mean?
A clone, fetch, or submodule update fails with fatal: could not read Username for the HTTPS remote: No such device or address.
How do I stop Git "could not read Username" with no terminal in CI happening again?
Always configure an explicit token or credential helper for HTTPS Git in CI, and set GIT_TERMINAL_PROMPT=0 so missing credentials fail fast instead of stalling.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card