$ git push -u origin main
remote: Invalid username or token. Password authentication is not supported for Git operations.
GitHub no longer supports username/password authentication for Git operations. Since August 2021, you must use one of these methods instead:
1. Use a Personal Access Token (PAT)
-
Click “Generate new token” → give it a name and expiration (e.g., 90 days).
-
Select scopes:
-
repo
→ for full repository access (read/write). -
workflow
→ if you want to push workflow files.
-
-
Click Generate token, copy the token once (you won’t see it again).
Now, in Git Bash:
When it prompts for a password, use the token instead of your GitHub password.
2. Use SSH Authentication (recommended)
-
Check if you have an SSH key:
-
If not, generate one:
-
Copy the public key:
-
Add it to GitHub: Settings → SSH and GPG keys → New SSH key
-
Change the Git remote to SSH:
Now you can push without entering username/password:
⚡ Quick Notes
-
Using PAT over HTTPS is simpler if you don’t want to configure SSH.
-
Once you enter a PAT once, Git can cache it using the Git Credential Manager on Windows.