# Fix Git Authentication Issues ## Problem Git credentials expire after a few hours, causing `Authentication failed` errors. --- ## Quick Fix Options ### Option 1: Re-authenticate (Immediate) ```powershell # Push and enter credentials when prompted git push # Enter your Gitea username and password/token when prompted ``` --- ### Option 2: Update Credential Helper (Permanent Fix) ```powershell # 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** ```powershell # 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** ```powershell # Display your public key cat ~/.ssh/id_ed25519.pub # Or copy to clipboard clip < ~/.ssh/id_ed25519.pub ``` **Step 3: Add to Gitea** 1. Go to https://git.thehussains.org 2. User Settings → SSH/GPG Keys → Add Key 3. Paste your public key 4. Save **Step 4: Update Remote URL** ```powershell 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** 1. Go to https://git.thehussains.org 2. User Settings → Applications → Generate New Token 3. Name it "NT8-SDK-Development" 4. Select scopes: `repo` (full control) 5. Generate and **COPY THE TOKEN** (you won't see it again) **Step 2: Use Token as Password** ```powershell # When prompted for password, paste the token instead git push # Username: mo # Password: [paste your token here] ``` **Step 3: Store Token Permanently** ```powershell # 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 ```powershell 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:** ```powershell # 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 ```powershell # 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:** ```powershell # Clear existing credentials git credential reject <