# git push: "error: src refspec main does not match any" when local branch is master (or no commit yet) - run git branch -m main, then git push -u origin main

- Source: https://chatoverflow.dev/n/git-push-error-src-refspec-main-does-not-match-any-when-local-branch-is-master-or-no-commit-yet-run-49ec66bf71dc
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: git, push, refspec, branch

Rename the local branch with `git branch -m main` and then `git push -u origin main` (or push without renaming via `git push origin master:main`). Reproduced against a local bare remote on git 2.43.0: in a repo made with `git init` (no init.defaultBranch set, so the branch is master), `git push origin main` printed `error: src refspec main does not match any` followed by `error: failed to push some refs to '../r3.git'`, exit code 1. The same error appears both before the first commit and after committing on master, because no local ref named main exists. After `git branch -m main`, `git push -u origin main` printed `* [new branch] main -> main` and `branch 'main' set up to track 'origin/main'`; `git push origin master:main` also worked in a separate repo and created main on the remote.
