Push origin master error on new repository
Question
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 'git@github.com:{username}/{projectname}.git'
Github's instructions:
Global setup:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email {username}@gmail.com
Next steps:
mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:{username}/{projectname}.git
git push origin master
Solution
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.
OTHER TIPS
I was having the same issue and then smacked myself in the head because I hadn't actually added my project files.
git add -A
git commit -am "message"
git push origin master
I had the same issue. I deleted the .git folder then followed the following commands
$ git init
$ git add .
$ git remote add origin git@gitorious.org:project/project.git
$ git commit -m "Initial version"
$ git push origin master
I have same issue . it's solved my problem . İf you init your git . you have to do on Terminal
1) git add .
2)git commit -m "first commit"
For send to bitbucket
3) git push -u origin --all # pushes up the repo and its refs for the first time
I just had the same problem while creating my first Git repository ever. I had a typo in the Git origin remote creation - turns out I didn't capitalize the name of my repository.
git remote add origin git@github.com:Odd-engine
First I removed the old remote using
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@github.com:Odd-Engine
No more error! :)
I had the same error, as Bombe said I had no local branch named master in my config, although git branch
did list a branch named master...
To fix it just add this to your .git/config
[branch "master"]
remote = origin
merge = refs/heads/master
Kinda hacky but does the job
make sure you are on a branch, at least in master branch
type:
git branch
you should see:
ubuntu-user:~/git/turmeric-releng$ git branch
* (no branch)
master
then type:
git checkout master
then all your changes will fit in master branch (or the branch u choose)
To actually resolve the issue I used the following command to stage all my files to the commit.
$ git add .
$ git commit -m 'Your message here'
$ git push origin master
The problem I had was that the -u command in git add didn't actually add the new files and the git add -A command wasn't supported on my installation of git. Thus as mentioned in this thread the commit I was trying to stage was empty.
i fixed my problem....
not sure what the problem was but using the gitx interface to commit my staged files, then...
$ git push origin master
worked...
i am having the same problem...
created a new folder added in the bort template files...
$ git commit -m 'first commit'
$ git remote add origin git@github.com:eltonstewart/band-of-strangers.git
$ git push origin master
then i get the same error...
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:eltonstewart/band-of-strangers.git'
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Unless you're generalizing the error message, it looks like you literally put git@github.com:{username}/{projectname}.git
as your remote Git repo. You should fill in {username}
with your GitHub username, and {projectname}
with your project's name.
cd app
git init
git status
touch test
git add .
git commit -a -m"message to log "
git commit -a -m "message to log"
git remote add origin
git remote add origin git@git.google.net:cherry
git push origin master:refs/heads/master
git clone git@git.google.net:cherry test1
I had same issue. I had mistakenly created directory in machine in lower case. Once changed the case , the problem solved(but wasted my 1.5 hrs :( ) Check it out your directory name and remote repo name is same.
It looks like this question has a number of answers already, but I'll weigh in with mine since I haven't seen any that address the issue I had.
I had this error as well on a brand new github repository. It turns out the user I was pushing from did not have push access. For some reason, this results in an "ERROR: repository not found" error instead of some sort of access error.
Anyway, I hope this helps the poor soul who runs into the same issue.
had the same issue a minute ago and then fixed it
create a repository in github called wordpress...
cd wordpress
git init
git add -A
git commit -am “WordPress 3.1.3″ or any message
git remote add origin git@github.com:{username}/wordpress.git
git push -u origin master
this should work to resolve the refspec issue
I mistankly put a space after the - so instead of -m I had - m Just something to look for.
I think in older version of git, you should commit at least one file first, and then you can "push origin master" once again.
great.. its the issue with empty directory only nothing else. I got my issue resolved by creating one binary file in each directory and then added them.
Initital add & commit worked like a charm. I guess it's just a matter of understanding Git's methodology of managing a project within the repository.
After that I've managed to push my data straight-away with no hassle.
I just encountered this problem, and it seemed to be caused by my not adding a custom commit message above the default commit message (I figured, why write "initial commit", when it clearly says that very same thing in the Git-generated text below it).
The problem resolved when I removed the .git directory, re-initialized the project directory for Git, re-added the GitHub remote, added all files to the new stage, committed with a personal message above the auto-generated message, and pushed to origin/master.
When you create a repository on Github, It adds a README.md file to the repo and since this file might not be there in your local directory, or perhaps it might have different content git push would fail. To solve the problem I did:
git pull origin master
git push origin master
This time it worked since I had the README.md file.
Before the first commit, try add some file like readme.txt. This will "force" the remote repo create the branch master in case that not exists. It's worked to me.
This is very old question but for all new people who will end up here like me. This solution is only for
error: src refspec master does not match any.
error for new repo created
You need to add your
git config user.email "your email"
git config user.name "name"
Only after adding email and name add files to git and commit
git add .
git commit -m "message"
It will work like charm
I have this error too, i put a commit for not push empty project like a lot of people do but doesn't work
The problem was the ssl, y put the next
git config --system http.sslverify false
And after that everything works fine :)
git push origin master
I was having same problem/error.I was doing git push -u origin master
instead i just did git push origin master
and it worked.
I had the same problem, some of the users have answered this. Before push you must have your first commit. Now for new users I've created a series of simple steps. Before that you need to install git and run in command line:
- git config user.email "your email"
- git config user.name "name"
The steps for creating a remote repository (I use dropbox as remote repository):
1. create a directory in Dropbox (or on your remote server)
2. go to the Dropbox dir (remote server dir)
3. type git command: git init --bare
4. on your local drive create your local directory
5. go to local directory
6. type git command: git init
7. add initial files, by typing git command:: git add <filename>
8. type git command: git commit -a -m "initial version" (if you don't commit you can't do the initial push
9. type git command: git remote add name <path to Dropbox/remote server>
10. git push name brach (for first commit the branch should be master)