sutee sutee - 8 months ago 63
Git Question

Push origin master error on new repository

I just started using git with github. I followed their instructions and ran into errors on the last step. I'm checking in an existing directory that isn't currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.

Here's what's happening:

$ git push origin master
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '{username}/{projectname}.git'

Github's instructions:

Global setup:

Download and install Git
git config --global "Your Name"
git config --global {username}

Next steps:

mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin{username}/{projectname}.git
git push origin master


The error message leads to the conclusion that you do not have a master branch in your local repository. Either push your main development branch (git push origin my-local-master:master which will rename it to master on github) or make a commit first. You can not push a completely empty repository.