Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Troubleshooting of GIT
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Git Push Failed: Invalid username or token (GitHub No Longer Supports Password Authentication) === '''Problem''' Running <code>git push</code> produces the following error: <pre> remote: Invalid username or token. Password authentication is not supported for Git operations. fatal: Authentication failed for 'https://github.com/your-org/your-repo/' In a case you entered incorrect password, please update it in Keychain Access application. </pre> '''Diagnosis''' First check the current login status of the GitHub CLI: <pre> gh auth status </pre> If the token has expired, a message similar to the following will appear: <pre> github.com X Failed to log in to github.com account UserName (keyring) * Active account: true * The token in keyring is invalid. * To re-authenticate, run: gh auth login -h github.com * To forget about this account, run: gh auth logout -h github.com -u UserName </pre> You can also directly query the GitHub credentials stored in the macOS Keychain: <pre> security find-internet-password -s github.com </pre> '''Cause''' This error is typically caused by one of the following: * An old GitHub account password (rather than a token) is stored in the macOS Keychain, and Git's attempt to authenticate with that password fails. * The Personal Access Token in the <code>gh</code> keyring has expired, been revoked, or had its permissions changed. * A token or SSH key was never set up, so Git is still falling back to the legacy password authentication flow. '''Solution''' '''Re-authenticate the GitHub CLI''' <pre> gh auth login -h github.com </pre> Select the following options in order: * What is your preferred protocol for Git operations on this host? → <code>HTTPS</code> (matches the existing remote protocol) * How would you like to authenticate GitHub CLI? → <code>Login with a web browser</code> A one-time code will be displayed. Copy it and press Enter; a browser window will open the GitHub device authorization page to complete the login: <pre> ! First copy your one-time code: XXXX-XXXX Press Enter to open https://github.com/login/device in your browser... ✓ Authentication complete. * gh config set -h github.com git_protocol https ✓ Configured git protocol ✓ Logged in as UserName </pre>
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki共筆:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)