Error src refspec master

Error src refspec master

Error src refspec master does not match any (QUICK FIX)

This post has the solutions to the error src refspec master does not match any, and error: failed to push some refs too.

The tips I share are the exact solutions I used to overcome the errors.

Contents

Error src refspec master does not match any

It isn’t a problem to work on your project and store it on your local drive isn’t a problem. However, storing the project on an online server requires an additional repo URL.

git remote add origin <MY-URL>

We push it like this:

Git push -u origin master

But it doesn’t always work. The following error is what comes out:

Error: src refspec master does not match any.

error: failed to push some refs to ‘<MY-URL>.’

OR

When pushing a new repository to Bitbucket Server, the following error is returned from the Git client:

git push -u origin master

error: src refspec master does not match.

error: failed to push some refs to  

 ‘http://stash.company.com/scm/PROJECT/REPO.git’

The repo is empty, and it is the cause of the problem. You don’t have any commits in the repo, and you need a master to give the server.

Solution

Create the first commit inside the repository, which can then be pushed. For example, the following will create an initial commit and push it to the server.

touch initial

git add initial

git commit -m “initial commit”

git push -u origin master

Here’s another solution:

Add and commit at least one change to your repo and re-run the push command. You can add e.g.

.gitignore.

Error: Failed To Push Some Refs To

You can read the text below the video if you don’t want to watch it. The following output can come up when you run Git:

To [email protected]:ola-s-test.git

! [rejected] your-branch -> your-branch (non-fast-forward)

Another person has pushed a commitment to that same branch. And the commit isn’t on your computer. You might wonder why this is happening. It is because you have not pulled in recent times, and another person has worked on that branch.

The simple solution is this:

git pull origin <your-branch>

git push origin <your-branch>

We can’t use a computer without getting errors here or there. We can only find solutions to each error as it arrives. The remaining part of this post explains some of the benefits and weaknesses of GitHub and whether GitHub is necessary.

Error src refspec master explained

Benefits Of GitHub

Anybody Can Contribute To Your Code

On GitHub, anyone can contribute to open-source code. It is just a matter of forking the project, modifying it, and pulling it back. The process is simple. This simplicity is one of the reasons GitHub is so popular.

I remember one of my friends back in college that was so lazy. We often make fun of him because he calls retrieving a project in GitHub work. Someone just starting as a developer will like the idea that GitHub is free. You can lay your hands on an extensive collection of projects without paying a dime. It is an incredible feeling to the serious-broke spirit of aspiring programmers.

Easy Documentation

GitHub has nearly all the documentation you will need to get a hold of Git. That is one. The documentation part of each project contains details of each part of the project. It is in this documentation you’ll find the function of each module.

Another critical piece of info you’ll find in the documentation is when each modification happened and the user that did it.

It Is A Geek Exhibition Platform

There have been countless stories where a programmer got hired after some recruiters searched for a specific person that meets their requirements on the GitHub platform. There is much usefulness of GitHub aside from just dropping and modifying projects.

Although you don’t have to wait for recruiters to find your profile, plant the link to your GitHub profile in your CV every time. However, you have to ensure you’ve got some lovely projects on GitHub or those you contribute to before showcasing your profile.

This simple tactic can be the only reason you will get the job. It is better than going to the best school in the world. Or the best code camp around. The recruiters usually want to know if the candidate can do the work, and what better answer than seeing a related work in your profile? For example, you want to hire someone to clean your garden. Your friend told you that his brother could do the job.

While thinking about it, you see your neighbor’s beautiful garden that he made by himself and offered to do the job for you. Who would you pick? You get the idea.

Weaknesses Of GitHub

Not So Secure

Companies that are serious about their projects will create a private Git for their projects. It is not that GitHub is wrong, but it is not a place for the critical projects that companies execute. GitHub has a private plan that isn’t free, which is what some companies use. Only the staff of such companies and selected individuals by the companies have access to the projects in the private plan.

Another reason people don’t like using GitHub for important work is the question of reliability. The reliability of any website online isn’t 100%, and a site like GitHub will have people trying to attack it now and then. So no one can vouch for GitHub on critical projects.

Price Can Be Very High

I don’t see any good reason why a company with an IT team would want to get the paid plan of GitHub. Just inform the team that you will need a server for Git. The features on GitHub that will be suitable for a company’s staff aren’t free and will be costly if the staff is many.

A company will be better off setting up its internal Git for the same purpose. You will see more reasons for that when considering the security aspect and the cost. I worked as an IT officer in a famous company right after graduating. Setting up and managing internal servers is one of the fun things I do. So setting up a Git should be easy for your IT team and developers.

Is GitHub Necessary

GitHub is a positive edge for a developer over other developers when seeking a job. That is not news. Out of every 1000 programmers’ CVs, 15% use GitHub, and 5% are active users of GitHub. This is the reason why recruiters want that 5% category of people. And it is the reason why GitHub is necessary.

Conclusion

You now have the solutions to the error src refspec master does not match any. Read again or send me a message if anything isn’t clear to you in this post.

Leave a Comment

Your email address will not be published. Required fields are marked *