Problem to publish project - GitHub

7

I'm trying to publish a project in GitHub, but every time I give a git push the message appears:

error: src refspec source does not match any.
error: failed to push some refs to 'https://github.com/user/project.git'

I have seen some solutions and none have solved them. Now this only started to appear, after I used GitHub for Windows, have anything to do?

    
asked by anonymous 12.06.2014 / 23:19

2 answers

9

Difficult to say with 100% certainty, but most likely the problem is that your local branch has a different name than the server branch (more precisely one of the two branches, local or remote, is not called master ).

To be sure, run the command git show-ref (which lists local references). A line should appear:

<algum SHA1>    refs/heads/master

And, just in case, run git ls-remote (which lists remote refineries). You should see a line with the same reference name:

<algum SHA1>    refs/heads/master

Would that be your problem?

Understanding ...

The (more) complete syntax of the git push command is:

git push <nome do remoto> <nome do branch local>:refs/heads/<nome do branch remoto>

When you use the syntax mentioned in the comments, git push origin master git assumes master both as local branch name and remote name.

You can use different names for the two branches, for this the complete form is used or it is set up in the file .git/config .

If you use the simplified form without such a configuration, the error message is exactly that: "refspec does not match any." . That is, the src (the local branch) part of refspec (which is the name of such a complete syntax with : ) did not match any other reference ). This "other reference" in the case is (implicitly) a reference of the remote origin in your example).

In other words: git tried to use the same name for the source and destination branches but did not find branches on both sides with the given name.

    
13.06.2014 / 03:40
1

When we create a project in place and apply the command git init . A branch master is automatically created.

When we create a new repository in github . A branch master is not automatically created. So the git push origin master command does not scroll. Why there is not a branch master on the remote yet.

How to solve this problem? Create the first commit and then apply git push . By default I create the file .gitignore soon after the git init command, as shown below:

touch .gitignore

git add .gitignore

git commit -m "gitignore file"

git push -u origin master
    
17.07.2018 / 22:15