• Register
1 vote
225 views

Problem :

I have cloned my current repository with below command :

git clone ssh://xxxxxx.com/project.git

But after I changed some of my files and added and committed them, I also wanted  to push them to my server with the help of below commands :

git add xxxx.php

git commit -m "TEST"

git push origin master

But I am facing below error :

error: src refspec master does not match any. 

error: failed to push some refs to 'ssh://xxxxxx.com/project.git'

6 5 3
7,540 points

2 Answers

0 votes

Solution :

Maybe you just need to do the commit. I ran into this in recent past when I executed below commands:

mkdir myrepo && cd myrepo
git remote add origin /path/to/the/origin.git
git add .

Oops! Here I Never committed! So got the below error after executing below command.

git push -u origin master
error: src refspec master does not match any.

So all I did was executing below commands:

git commit -m "initial commit"
git push origin master

As you can see I committed my changes and I got Success!

OR

1. You can try git show-ref to see what are the refs you having. Check if its there a refs/heads/master?

2. You can also  try the git push origin HEAD:master as the more local-reference-independent solution. This will explicitly state that you want to push your local ref HEAD to yur remote ref master

9 7 4
38,600 points
0 votes

Solution:

Maybe you only require to commit. I ran into this when I did:

mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .
git push -u origin master
error: src refspec master does not match any.

All You need to do this:

git commit -m "initial commit"
git push origin master
  1. Attrmpt git show-ref to see what refs you have. Is there a refs/heads/master?

  2. You can attempt git push origin HEAD:master as a more local-reference-independent solution. This apparently states that you want to push the local ref HEAD to the remote ref master (see the git-push refspec documentation).

I also had a same error after deleting all files on my local computer, and I have to tidy up all files in the repository.

My error message was  like this:

error: src refspec master does not match any.
error: failed to push some refs to 'git@github ... .git'

And it was solved by acting the following commands:

touch README
git add README

git add (all other files)
git commit -m 'reinitialized files'
git push origin master --force  # <- caution, --force can delete others work.
  1. My changes were formerly committed

  2. Force push still gave me the similar error.

So I attempted Vi's solution:

git push origin HEAD:<remoteBranch> 
git push -u origin master
error: src refspec master does not match any.

For that you require to enter the commit message as follows and then push the code:

git commit -m "initial commit"

git push origin master

From git branch it looks that somehow your local branch name is "origin".

You can rename the branch with -mv flag, like this:

git branch -mv origin master

After this git branch should show master :-)

Only to ensure that the name is truly the only thing that went astray, you can run git log and look at the last few commits - and compare them to the last several commits on bitbucket website.

10 6 4
31,120 points

Related questions

0 votes
1 answer 90 views
90 views
Problem : When I compile the Python code I get below error IndentationError: unindent does not match any outer indentation level
asked Oct 21, 2019 peterlaw 6.9k points
1 vote
1 answer 47 views
47 views
Problem : I have recently started to learn the GIT. I was working on my GIT and suddenly I started facing below error. &ldquo;Fatal: not a git repository (or any of the parent directories): .git&rdquo; As I am very new to GIT so I am unable to understand above error ... the error from past couple of days but unable to fix it. Is there anyone who can spare some time and guide me to fix above error?
asked Mar 30 morrisBson 3.2k points
1 vote
1 answer 24 views
24 views
Problem: For my project I wrote this code: def create_train_data(): trainday_data = [1100] for img in tqdm(os.listdir(TRAIN_DIR)): label = label_img(img) path = os.path.join(TRAIN_DIR, img) training_data.append([np.array(img), np.array(label)]) ... np.save('train_data.npy', training_data) ^ IndentationError: unindent does not match any outer indentation level Please help me to fix this poblem.
asked Apr 7 LizzyM 6.1k points
0 votes
1 answer 59 views
59 views
PROBLEM: Python programming is new to me . I wrote a code which gives me following error: python indentationerror: unindent does not match any outer indentation level The code I wrote is: import sys def Function(x): result = 1 for i in range (1,x): result = result * i * i print ("Your factorial is ",result) return result print (Function(10))
asked Mar 18 LizzyM 6.1k points
0 votes
1 answer 114 views
114 views
Problem : When I try to compile my Python code below, I get below error &ldquo;IndentationError: unindent does not match any outer indentation level&rdquo; import sys def Factorial(n): # Return the factorial     myresult = 1     for j in range (1,n):         myresult = myresult * j     print "The factorial is: ",myresult     return myresult Why am I getting above error?
asked Jan 22 jwilliam 3.9k points