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 OverflowMaybe 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!
- Try
git show-refto see what refs you have. Is there arefs/heads/master?
Due to the recent "Replacing master with main in GitHub" action, you may notice that there is a
refs/heads/main. As a result, the following command may change fromgit push origin HEAD:mastertogit push origin HEAD:main
- You can try
git push origin HEAD:masteras a more local-reference-independent solution. This explicitly states that you want to push the local refHEADto the remote refmaster(see the git-push refspec documentation).
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.
Error: src refspec main does not match any
I get "refspec main does not match any" on setup
How to fix “error: src refspec main does not match any”?
Src refspec master does not match any
Need help pushing my code onto GitHub but I keep getting this error