3.9 KiB
3.9 KiB
Fix Git Authentication Issues
Problem
Git credentials expire after a few hours, causing Authentication failed errors.
Quick Fix Options
Option 1: Re-authenticate (Immediate)
# Push and enter credentials when prompted
git push
# Enter your Gitea username and password/token when prompted
Option 2: Update Credential Helper (Permanent Fix)
# Set credential helper to store credentials permanently
git config --global credential.helper store
# Or use Windows Credential Manager (recommended for Windows)
git config --global credential.helper wincred
# Or use manager-core (modern credential manager)
git config --global credential.helper manager-core
# Then push - it will ask for credentials ONE TIME and remember
git push
After running one of these, the next git push will prompt for credentials once and then remember them.
Option 3: Use SSH Instead of HTTPS (Best Long-term)
This eliminates password prompts entirely.
Step 1: Generate SSH Key
# Generate new SSH key
ssh-keygen -t ed25519 -C "your-email@example.com"
# Press Enter to accept default location: C:\Users\YourName\.ssh\id_ed25519
# Enter a passphrase (or press Enter for no passphrase)
Step 2: Copy Public Key
# Display your public key
cat ~/.ssh/id_ed25519.pub
# Or copy to clipboard
clip < ~/.ssh/id_ed25519.pub
Step 3: Add to Gitea
- Go to https://git.thehussains.org
- User Settings → SSH/GPG Keys → Add Key
- Paste your public key
- Save
Step 4: Update Remote URL
cd C:\dev\nt8-sdk
# Check current remote
git remote -v
# Change from HTTPS to SSH
git remote set-url origin git@git.thehussains.org:mo/nt8-sdk.git
# Verify change
git remote -v
# Now push with SSH (no password needed)
git push
Option 4: Use Personal Access Token
Step 1: Create Token in Gitea
- Go to https://git.thehussains.org
- User Settings → Applications → Generate New Token
- Name it "NT8-SDK-Development"
- Select scopes:
repo(full control) - Generate and COPY THE TOKEN (you won't see it again)
Step 2: Use Token as Password
# When prompted for password, paste the token instead
git push
# Username: mo
# Password: [paste your token here]
Step 3: Store Token Permanently
# Configure credential helper
git config --global credential.helper store
# Push once with token
git push
# Enter username and token when prompted
# Future pushes won't require credentials
Recommended Solution
For now (immediate): Use Option 2
git config --global credential.helper manager-core
git push
# Enter credentials once, will be remembered
For best security: Use Option 3 (SSH keys)
- No passwords to remember
- More secure
- Works across all Git operations
- One-time setup
Current Status - What to Do Now
Immediate action:
# Quick fix - store credentials
git config --global credential.helper store
# Push with credentials
git push
# Enter your Gitea username and password
# Credentials will be stored for future use
Verify Credential Helper
# Check what credential helper is configured
git config --global credential.helper
# Should show one of:
# - store
# - wincred
# - manager-core
Troubleshooting
If credentials still don't work:
# Clear existing credentials
git credential reject <<EOF
protocol=https
host=git.thehussains.org
EOF
# Try push again with fresh credentials
git push
If using 2FA on Gitea:
- You MUST use a Personal Access Token, not your password
- See Option 4 above
After Fixing Auth
Once authentication is working, continue with the Phase 5 commit:
# Verify you can access remote
git fetch
# Push your commits
git push
# Should succeed without authentication errors
Recommended: Run Option 2 now, then switch to SSH (Option 3) when you have time.