Shi Zhang
Shi Zhang

Reputation: 163

`git push origin master` does not work

I cloned a remote repo using (vars names changed--I have to hide the URL because of security purposes.)

git clone -b someLocalRepo github.com/someRemoteRepo.git someLocalRepo

(unsure what the -b flag is for if I specified at the end what I want the repo to be named as on my computer...)

Made some changes and then did

git add -A
git commit -m "testing git"

I read online that I'm supposed to do git push origin master but it throws me the following error:

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

I did several searches but could not figure out why. Can someone explain what's going on here?

Note: git push and git push origin works

Upvotes: 0

Views: 6251

Answers (1)

phd
phd

Reputation: 95028

git clone -b someLocalRepo means "clone the repository and check out that named branch". And this is exactly your problem — your repository doesn't have branch someLocalRepo so you're not on any branch now.

To fix that check out an existing branch. Let's try master:

cd someLocalRepo
git checkout master

Now git push origin should work.

Upvotes: 2

Related Questions