git push_error ai_generated true

error: src refspec 'main' does not match any

ID: git/src-refspec-no-match

Also available as: JSON · Markdown
95%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

Pushing a branch that doesn't exist locally. Common: no commits yet, or wrong branch name.

generic

Workarounds

  1. 95% success Make sure you have at least one commit: git add . && git commit -m 'initial'
    git add . && git commit -m 'initial'

    Sources: https://git-scm.com/docs/git-commit

  2. 92% success Check current branch name: git branch — default may be 'master' not 'main'
    git branch — default may be 'master' not 'main'

    Sources: https://git-scm.com/docs/git-branch

Dead Ends

Common approaches that don't work:

  1. Force push 90% fail

    Can't force push a non-existent branch — the branch literally doesn't exist

  2. Create empty branch with checkout --orphan 70% fail

    Need at least one commit to push

Error Chain

Frequently confused with: