# Fix “src refspec does not match any” without guessing

Canonical: https://githtml.com/guides/git-src-refspec-does-not-match-any
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

“Src refspec does not match any” means Git could not resolve the local source you asked it to push. Common causes are a misspelled branch name, a different initial branch name, or no successful commit yet. Inspect local refs and the commit state before changing branch names, remotes, or history.

## Read the source side of the error

In a command such as git push origin main, main is a local source name. A remote branch named main does not automatically create a local branch with that name. Likewise, an initial branch can be reported in status before any commit establishes the branch reference. This is why a new repository can appear to be on main but still have nothing pushable.

Do not delete .git or use force-push to solve a missing source name. Neither creates the intended commit safely. A previous commit attempt may have failed because of identity, hooks, or an empty staged snapshot; read that earlier output rather than assuming the commit exists.

## Inspect branch names and the first commit

These checks reveal the current branch, known local branches, and whether HEAD resolves to a commit. A failure of rev-parse in an empty repository is useful evidence. Confirm the remote URL as a separate destination check. Replace example branch names only after seeing the actual local state.

1. If the intended work is committed on another local branch, push that verified branch or deliberately rename it according to project policy; do not overwrite an existing name.
2. If there is no commit, review and stage the real project changes, correct the reason the commit failed, and create the intended first commit before publishing.

````shell
git status --short --branch
git branch --show-current
git branch --list
git rev-parse --verify HEAD
git remote -v
````

## Retry with an explicit verified source

Once the local branch exists and points to the intended commit, retry a narrowly scoped push to the authorized remote. A later non-fast-forward or permission rejection is a different problem and needs its own diagnosis. Do not keep adding flags to the original command until every safeguard is bypassed. Verify the branch online afterward and compare the commit identifier, because a successful push to an unintended branch does not satisfy the original task.

Use the branch name exactly as listed, including case. Renaming a branch is a separate intentional action and should not be performed merely because an online example assumed a different default name.

1. For a new repository, compare the output of status with rev-parse --verify HEAD. An initial branch label alongside a failed HEAD lookup means no commit reference exists yet. Adding an upstream setting cannot substitute for successfully creating the project’s first reviewed commit.
2. If your command specifies a source and destination separated by a colon, inspect the source on the left first. A correctly spelled destination cannot repair a nonexistent local source. Once that source resolves, confirm its commit contains the intended files before retrying the same destination.

## Sources and further reading

- [Git reference: git-push](https://git-scm.com/docs/git-push)
- [Git reference: git-branch](https://git-scm.com/docs/git-branch)
- [Git reference: git-commit](https://git-scm.com/docs/git-commit)

## Related guides

- [Fill an empty submodule directory after cloning](https://githtml.com/guides/git-submodule-directory-empty-after-clone)
- [Move uncommitted work to the right Git branch](https://githtml.com/guides/git-uncommitted-changes-wrong-branch)
- [Undo an unpublished Git commit while keeping its edits](https://githtml.com/guides/git-undo-local-commit-keep-changes)
- [Resolve “unmerged files” before continuing Git](https://githtml.com/guides/git-unmerged-files-resolve-conflict)

Editorial approach: https://githtml.com/guides/about
