THE GITHTML FIELD GUIDE
Diagnose GitHub HTTPS authentication failures
For GitHub HTTPS Git operations, use a supported authentication method such as a credential manager, GitHub CLI sign-in, or an appropriate personal access token; account passwords are not accepted for Git operations. If authentication fails, verify the stored account, credential validity, repository selection, and organization policy before changing remote history or broadening permissions.
Identify the credential source
A browser session and a terminal credential helper can use different accounts. Re-entering a browser password at a Git prompt does not align them. Inspect the remote protocol and the credential helper configuration, then use the helper’s documented account-management flow to determine which identity is being supplied.
Tokens can expire, be revoked, lack access to the selected repository, or await organization approval. A fine-grained token’s resource owner and repository selection matter independently of its permissions. Do not solve a narrow read failure by granting every available permission. First identify whether the failure is authentication, authorization, or a repository policy blocking the particular operation.
Run narrow checks without leaking credentials
These commands inspect the destination and helper, then test repository reading. Do not place a token directly in the URL or command line, where it can enter shell history and logs. Use an approved credential prompt or secure helper. If the remote is SSH, use SSH troubleshooting instead of this HTTPS path.
- Refresh only the stale credential associated with the relevant account and host; avoid clearing every credential on a shared machine without understanding the consequences.
- Check the repository owner’s access policy and the token’s selected repositories before requesting broader permissions or creating another long-lived credential.
git remote get-url origin
git config --show-origin --get-all credential.helper
git ls-remote originVerify read and write needs separately
After authentication works, a push can still be rejected because the account lacks write access or the branch requires review. That is not evidence that the token needs administrator permissions. Follow the project’s contribution workflow and test only the capability your task actually needs.
If a credential was exposed in a URL, screenshot, or transcript, revoke or rotate it through the account’s security controls and remove unsafe stored references. Never ask another person to send you their token to compare behavior. A useful support report identifies the sanitized host, protocol, account, operation, and error without reproducing secrets. Finish by confirming the intended account can perform the authorized operation through the secure credential mechanism.
- If one terminal works but your editor fails, inspect which credential helper each environment actually invokes. They may use different Git executables, accounts, or stored sessions. Repair the failing environment’s credential selection instead of revoking a working token before identifying where the mismatch occurs.
- When a token has expired, replace it through the approved credential flow and confirm that the replacement retains only the required repository selection and permissions. An expiration fix should not quietly become a larger access grant. Test the same previously failing read operation to establish the result.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.