Interview Prep/Git & GitHub/Authentication and Remote Access

`fatal: Authentication failed for 'https://github.com/org/repo.git/'` with a token that worked last month.

BeginnerTroubleshootingAuthentication and Remote Access
Answer

Likely causes → The token expired or was revoked, a stale token is cached by the credential helper, or the token lost access to the repo.

Diagnose →

git config --get-all credential.helper
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git ls-remote origin 2>&1 | tail -20

Fix → Remove the cached credential (printf 'protocol=https\nhost=github.com\n\n' | git credential reject), create a new token, and retry so the helper stores the new one.

Prevent → Prefer SSH or gh auth over long-lived tokens, and calendar token expiry dates.

All Git & GitHub questions Roadmap: Git & GitHub

More on Authentication and Remote Access