error: src refspec main does not match any
You pushed a branch name that doesn’t exist locally — usually no commits yet, or the branch is called master not main.
Seen on:
Git
Meaning
A new repo has no branch until the first commit. Pushing main when your local branch is master (or vice versa) also fails.
Common causes
- No commits yet
- Local branch named master/main differently
- Typo in the branch name
⚡ Quick fix
- Commit first: git add . && git commit -m "Initial commit"
- Check git branch and push the right name
- Rename: git branch -M main
Detailed fix by platform
Git
git branch -M main && git push -u origin main
How to diagnose
- Branches — git branch output
- Commits — git log works?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026