Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Push origin master error on new repository

Git push origin master error on new repository. Check if the remote repository exists and is correctly configured.

Quick Answer: Check if the remote repository exists and is correctly configured. Run 'git remote -v' to verify the URL, then try again with 'git push origin master --force' or 'git push origin master --force-with-lease'. If issues persist, check GitHub's documentation for specific instructions on pushing a new repository.

The error message 'src refspec master does not match any' indicates that the remote repository is not aware of your local branch. This can happen when you're pushing a new branch to the remote repository without first creating it on the remote side.

🛑 Root Causes of the Error

  • The repository is not aware of your local branch.

🛠️ Step-by-Step Verified Fixes

Method 1: Update the Remote Repository

  1. Step 1: Run `git fetch origin` to update your local copy of the remote repository.

Method 2: Create a New Branch on the Remote Repository

  1. Step 1: Run `git push -u origin {branch-name}` to create a new branch on the remote repository and set it as the default branch.

🎯 Final Words

To avoid this error in the future, make sure to create a new branch on the remote repository before pushing your changes. You can also use `git push -u origin master` to set up the default branch.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions