How to Fix "error: src refspec main does not match any" in Git Push
Git rejects git push origin main because the local repository has no commits yet, or the local branch is still named "master" rather than "main".
error: src refspec main does not match any
Quick Fix Checklist
- Check existing local branch: git branch
- Ensure changes are staged and committed: git add . && git commit -m "Initial commit"
- Rename branch to main: git branch -M main
- Push to GitHub upstream: git push -u origin main