1

I am getting the following errors when I try to push to my github repo:

error: src refspec BRANCH does not match any.
error: failed to push some refs to 'https://github.com/

I have gone through numerous SO answers but couldn't find a solution.

git show-ref

doesn't show anything. What is the problem and how can I fix it?

2
  • What is the command you used for pushing? Commented Jun 1, 2016 at 17:32
  • git push origin master. I also tried git push -u origin master. Commented Jun 1, 2016 at 17:35

1 Answer 1

1

A possible workaround is to clone your GitHub repo and report your commits from your previous local repo

git clone https://github.com/<user>/<repo>
cd <repo>
git remote add firstrepo ../firstrepo
git fetch firstrepo
git branch -avv
git checkout -b fmaster firstrepo/master 
git rebase master
git checkout master
git push

But if you don't want to re-import your local repo in a new clone, check your remote and branches:

git remote -v
git branch -avv

You git config --local -l should look like:

remote.origin.url=https://github.com/<user>/<repo>
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

Since git branch -avv shows nothing, make sure you have added and committed first something, before attempting any git push:

git config user.name <GitHub account Name>
git config user.email <GitHub account email>
git add .
git commit -m "First commit"
git push -u origin master
Sign up to request clarification or add additional context in comments.

7 Comments

When I tried git push -u origin --all it said No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'.
@RaviTej310 Hence my suggestion to check the output of git remote -v and git branch -avv. We'll know more then.
git remote -v output: origin https://github.com/RaviTej310/Andrew_Ng_Machine_Learning.git (fetch) origin https://github.com/RaviTej310/Andrew_Ng_Machine_Learning.git (push) and git branch -avv shows nothing
git config --local -l shows core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=https://github.com/RaviTej310/Andrew_Ng_Machine_Learning.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
@RaviTej310 make sure your repo does not include too many object/files. Creating a repo under / would be a bad idea, as a git add would add all the content of / (and subfolders). Try with a small repo first. Any push will push commits. If you don't add and create commits, you cannot push.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.