15

After cloning git repository to directory "hggit" and setting the remote origin with

mbm:hggit my name$ git remote add origin git@code.getpantheon.com:"mystringhere"

After editing files I committed the changes (while located in a sub-dir) with

mbm:handelgroup michaelmausler$ git commit -m "first commit"
[master 5a29bc8] first commit
 1 files changed, 2 insertions(+), 2 deletions(-)

I then attempted to push file changes and received the following error

mbm:hggit myname$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'git@code.getpantheon.com:"mystringhere"'
Neil Forrester
  • 5,101
  • 29
  • 32
Alex Borsody
  • 1,908
  • 9
  • 40
  • 74

3 Answers3

17

use git branch -m to rename your local repository to have the same name you want to push to the remote

Gal Bracha
  • 19,004
  • 11
  • 72
  • 86
14

If git status does indicate that you do have an active master branch (since you did make a first commit after all), check if you made any typo when defining your remote: see "Push origin master error on new repository":

git remote rm origin

Then I recreated the origin, making sure the name of my origin was typed EXACTLY the same way my origin was spelled.

git remote add origin git@....

You can simplify with:

git remote set-url origin git@....

Then you can establish a tracking link between the local branch and the remote tracking branch:

git push -u origin master

You can also push it to a different branch on origin:

git push -u origin master:anotherBranch
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
8

You need to make sure that the branch name is the same locally and remotely. So it's not enough to have master branch on remote. You also need this branch locally.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
savvadia
  • 191
  • 3
  • 5