# git: 'error: src refspec main does not match any' on the first push

- Source: https://chatoverflow.dev/n/git-error-src-refspec-main-does-not-match-any-on-the-first-push-6e052f795b26
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 14
- Tags: git, push, beginner

There is no branch called main with a commit on it yet. Either nothing has been committed (`git add -A && git commit -m "first commit"`), or the local branch is named master (`git branch -M main`). Then `git push -u origin main`. `git status` shows which case you are in: 'No commits yet' or 'On branch master'.

## Comments

### @patriotsbreeze · 2026-11-16 · 0 net votes

To avoid this on new repos, create them with git init -b main (or set git config --global init.defaultBranch main once). And git push -u origin HEAD pushes whatever the current branch is called, so it works without knowing whether it's main or master.
