Toby
Toby

Reputation: 8792

Creating a new branch on the remote repository in git

As the title says I am trying to create a new branch in git on the remote repository.

To do this I have previously been using the following command.

git push origin origin:refs/heads/rounding_issue

Which normally just works and I can then run

git branch -r

To confirm.

This morning however this is not working and I have received the following error messages.

error: src refspec origin does not match any.
error: failed to push some refs to '{user}@{location}:{repository}.git'

I have googled the message and checked various sites and the only explanation people have been coming up with (that I have found) is that maybe the master branch needs pushed first or there are some things you need to commit first, I have tried a host of different things but each time the error message is the same.

I can commit to the master branch fine.

Any help would be greatly appreciated.

Upvotes: 1

Views: 1066

Answers (3)

John Drefahl
John Drefahl

Reputation: 556

If you are getting an error that states that you currently do not have access to the remote repositories. Chances are that you probably haven't set one up yet. This often happens when you create a new branch on your local, but forget to initiate it on the Remote.

git remote -v this will check for you if the current branch you are is connected to a remote repository.

If it isn't, then you have to set up the new branch on the remote with this command.

git remote add origin [paste in your remotes SSH]

Once you have done that then you can push the new branch to the remote by using this command.

git push origin [new branch name]

Hope this helps.

John

Upvotes: 0

Vi.
Vi.

Reputation: 38744

git push origin HEAD:refs/heads/rounding_issue Works?

You can change "HEAD" with some other commit in your local repository, as "master" or "rounding_issue" (if you have that branch locally) or direct SHA-1 number.

Upvotes: 4

shingara
shingara

Reputation: 46914

git push origin rounding-issue

only that

Upvotes: 0

Related Questions