src refspec 🌿 Git

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

  1. Commit first: git add . && git commit -m "Initial commit"
  2. Check git branch and push the right name
  3. Rename: git branch -M main

Detailed fix by platform

Git

  1. git branch -M main && git push -u origin main

How to diagnose

  1. Branches — git branch output
  2. 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.