Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"src refspec does not match" and "failed to push some refs" errors on git push [duplicate]

Possible Duplicate:
Error when “git push” to github

I tried to push my new branch (let's just call it new_branch) to remote rep. There is no such branch there yet, but git push origin new_branch:new_branch should create it. When I try to do it, this is what I get:

error: src refspec new_branch does not match any.
error: failed to push some refs to 'ssh://git@***'

I dug through million of questions like this on SO, but none of them specified these two errors at once and they referred only to master branch (I don't know if it makes any difference).

What I already tried include commit, reset and push in many configurations. And they didn't work so far. I suppose there may be some issue with HEAD, because I messed with it some time ago. But it's a guess and I don't even know how to check it properly, since GIT is still a teeny-tiny mystery for me.

So - how can I get rid of these errors and push my local branch to remote repository?

like image 515
alex Avatar asked Aug 30 '12 16:08

alex


People also ask

How do you fix SRC Refspec main does not match any?

The solution to this error is to either create a local and remote master branch that you can push the commit to or to push the commit to an existing branch – maybe main . These commands will create a master branch locally. And by pushing to origin master , the master branch will also be created remotely.

What is SRC Refspec master does not match any?

The “src refspec master does not match any” error occurs if you have forgotten to add the files you have changed to a commit and try to push those changes to a remote repository before you make the first commit in your repository.

How do you push origin master?

Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.

How do I push a local branch to remote branch?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.


1 Answers

The syntax you're using for git push includes a refspec (new_branch:new_branch). Refspecs are always in the form source:destination, so the error is telling you that something's wrong with the source part of your refspec.

I was able to reproduce this error by trying to push a branch that doesn't exist (git push origin fake:fake). I know this seems like a painfully stupid question, but are you sure you're spelling your branch name correctly? Keep in mind that branch names are case-sensitive. What do you see when you type git branch?

like image 196
Ethan Brown Avatar answered Sep 29 '22 17:09

Ethan Brown