Maybe you just need to commit. I ran into this when I did:

mkdir repo && cd repo
git init
git remote add origin /path/to/origin.git
git add .

Oops! Never committed!

git push -u origin master
error: src refspec master does not match any.

All I had to do was:

git commit -m "initial commit"
git push origin main

Success!

Answer from baisong on Stack Overflow
🌐
Reddit
reddit.com › r/git › error while using git push error: src refspec not match any
r/git on Reddit: Error while using git push error: src refspec not match any
March 19, 2024 -

I want to push the changes in my local repo to remote repo in a certain branch.

>git push -f https://gitlab.xyz.com/<path> Upgrade-qa

error: src refspec Upgrade-qa does not match any

error: failed to push some refs to 'https://gitlab.xyz.com/<path>.git'

Earlier to this I performed the set of commands like

>git init

>git remote add origin <remote repo path>

>git add .

>git commit -m "QA Upgrade"

> git push -f https://gitlab.xyz.com/<path> Upgrade-qa

While I searched on the same issue , I found that people would suggest to use 'git pull' with rebase option.

I am new to git and in my local repository I have made the changes. All the changes I want to push it to remote repo in a certain branch. I am afraid if I would use 'git pull' then all the remote repo code would be merged to my local repo then how I would be able to merge my local changes to remote.

I still feel unsafe because if I use git pull my local codebase in the local repo would be subjected to change but I wish to continue working on my local repo from the same instant again.

Discussions

Src refspec master does not match any
Dear GitLab community, out of sudden my deployment jobs are failing with message “src refspec master does not match any”. I did some research and I have absolutely no idea why. However, when I compare current deployment job log with previous one I see this difference: Current (Not working): ... More on forum.gitlab.com
🌐 forum.gitlab.com
17
1
March 16, 2019
error: src refspec master does not match any
I have a lot of repo on bitbucket and never had an issue but today, when trying to create a new one, i seem to cannnot set a default master branch, i set it in the repo creation but when i try to push my local code to the repo i get the following: git push origin master error: src refspec master ... More on community.atlassian.com
🌐 community.atlassian.com
September 25, 2024
How to fix “error: src refspec main does not match any”?
I’m trying to push my code to GitHub but getting error: src refspec main does not match any. I’m not sure if it’s a branch issue or something else. Has anyone solved this before? More on forum.getassist.net
🌐 forum.getassist.net
3
0
December 2, 2025
Error while using git push error: src refspec not match any
If you want to push your current branch to Upgrade-qa on the remote, the command is git push origin HEAD:Upgrade-qa. More on reddit.com
🌐 r/git
6
0
March 19, 2024
🌐
Sentry
sentry.io › sentry answers › git › git src refspec master does not match any error message
Git src refspec master does not match any error message | Sentry
March 15, 2023 - To resolve the issue, first check the push command. For example, if you’ve changed the primary branch name from master to main, running git push origin master will produce this error message, and you should run git push origin main instead.
🌐
freeCodeCamp
freecodecamp.org › news › error-src-refspec-master-does-not-match-any-how-to-fix-in-git
Error: src refspec master does not match any – How to Fix in Git
August 1, 2022 - So if you get the Error: src refspec master does not match any error when you try to push to master, the most viable reason is that the master branch does not exist.
🌐
Atlassian Support
support.atlassian.com › bitbucket-data-center › kb › error-when-pushing-to-repository-src-refspec-master-does-not-match-any
Error when pushing to repository: Src refspec master does not match any | Bitbucket Data Center | Atlassian Support
April 15, 2025 - Create the first commit inside of the repository and then it can be pushed. For example, the following with create an initial commit and push it to the server. touch initial git add initial git commit -m "initial commit" git push -u origin master
🌐
GitHub
github.com › orgs › community › discussions › 163792
Facing error: “src refspec master does not match any.” · community · Discussion #163792
There was an error while loading. Please reload this page. ... If it says main, and you tried to push master — that’s the issue. Step 2: Make sure you’ve committed at least once If it’s a brand new repo, you must stage and commit something first: Step 3: Push the correct branch If your branch is main, push like this: git push origin main If it’s master, then:
Find elsewhere
🌐
Coderanch
coderanch.com › t › 742117 › build-tools › error-src-refspec-main-match
error: src refspec main does not match any (Other Build Tools forum at Coderanch)
The real solution is to ask yourself why you're trying to add these files to your source repository in the first place. You should only add hand-coded source files; not binaries, generated source files or tools. What does your .gitignore file look like? You should set it up so it ignores everything ...
🌐
GitLab
forum.gitlab.com › gitlab ci/cd
Src refspec master does not match any - GitLab CI/CD - GitLab Forum
March 16, 2019 - Dear GitLab community, out of sudden my deployment jobs are failing with message “src refspec master does not match any”. I did some research and I have absolutely no idea why. However, when I compare current deployment job log with previous one I see this difference: Current (Not working): Running on runner-72989761-project-4417089-concurrent-0 via runner-72989761-srm-1552747221-b30389b8…
🌐
Atlassian Community
community.atlassian.com › q&a › bitbucket › questions › error: src refspec master does not match any
error: src refspec master does not match any
September 25, 2024 - Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. ... Those new to the Atlassian Community have posted less than three times. Give them a warm welcome! ... I have a lot of repo on bitbucket and never had an issue but today, when trying to create a new one, i seem to cannnot set a default master branch, i set it in the repo creation but when i try to push my local code to the repo i get the following: git push origin master error: src refspec master does not match any error: failed to push some refs to 'https://bitbucket.org/******/frontend.git'
🌐
Itsourcecode
itsourcecode.com › home › error: src refspec master does not match any [solved]
Error: SRC Refspec Master Does Not Match Any [SOLVED] - Itsourcecode.com
August 17, 2022 - SOLVED! Error: SRC Refspec Master Does Not Match Any" happens when you forget to add the files you changed to a commit and try to push those
🌐
Hire Tech Firms
hiretechfirms.com › home › how to fix this error: src refspec master does not match any in git
How to Fix This Error: src refspec master does not match any in Git
October 31, 2024 - The error message essentially indicates that Git cannot find a branch or commit that matches the specified refspec—in this case, `master`. A refspec is a way to specify which references (branches or tags) you want to work with in Git operations.
🌐
GetAssist
forum.getassist.net › how-to guides
How to fix “error: src refspec main does not match any”? | GetAssist Forum
December 2, 2025 - This Git error occurs when the branch name doesn’t exist or has no commits. Fix it by ensuring you’ve made an initial commit, then use git branch to check branch names. If needed, run git push origin main or replace “main” with the correct branch like “master.”
🌐
Qiita
qiita.com › git
初回git push 時の「src refspec master does not match any」解決法 #Git - Qiita
January 18, 2022 - エラー内容 新規アプリを作成し、pushした際に以下のエラーが出力された。 $ git push error: src refspec master does not match any error: failed to push some refs to 'github...
🌐
Verve AI
vervecopilot.com › hot-blogs › src-refspec-main-error-interview
What Does Error: Src Refspec Main Does Not Match Any Mean For Your Interview… · Refspec Main Error Interview · Hot blog | Verve AI
Technically, error: src refspec main does not match any appears when Git can’t find the branch or reference you’re trying to push. Common root causes are: the local branch doesn't exist, the branch has no commits yet, or you’re using the wrong branch name (e.g., master vs main).
🌐
Alibaba Cloud
developer.aliyun.com › article › 398905
Git:错误:error:src refspec master does not match any-阿里云开发者社区
July 3, 2020 - error:src refspec master does not match any · 百度下,原来是说我本地没有提交任何东西,本地版本库为空, 空目录不能提交 (只进行了init, 没有add和commit)。 · 解决: · 添加:git add -A · 提交:git commit -m "first commint" 强制推送:git push -f orgin master ·
🌐
GitHub
gist.github.com › pebriana › b3a08c1d9137c5fbbb0a
error: src refspec master does not match any. error: failed to push some refs to 'ssh://xxxxx.com/project.git' · GitHub
Clone this repository at &lt;script src=&quot;https://gist.github.com/pebriana/b3a08c1d9137c5fbbb0a.js&quot;&gt;&lt;/script&gt;
🌐
Hashnode
anandwadsinge.hashnode.dev › git-src-refspec-main-does-not-match-any
GIT - src refspec main does not match any
September 4, 2023 - The error message "src refspec main does not match any" typically occurs when you are trying to push changes to a branch named "main" in a Git repository, but the branch does not exist or does not have any changes to be pushed.
🌐
Laracasts
laracasts.com › discuss › channels › laravel › error-src-refspec-master-does-not-match-any
error: src refspec master does not match any
I did that git init git add . git commit -m "initial commit" git remote add origin https://github.com/d/site.git git push -u origin master error git push -u origin master error: src refspec master does not match any error: failed to push some refs to 'https://github.com/d/site.git' and thank you
🌐
Medium
jcmartinezdev.medium.com › how-to-fix-error-src-refspec-master-does-not-match-any-in-git-7efed520783f
How to Fix: Error: Src Refspec Master Does Not Match Any in Git | by Juan Cruz Martinez | Medium
March 29, 2023 - The error message “src refspec master does not match any” is usually caused by Git when pushing changes and not finding the master branch in your remote repository.