src refspec ~ does not match any
Asked Answered
L

2

9

Hi I want to push something to specific remote branch

I make local areas by

git clone https://~~~.Something
cd https://~~~.Something

and I can access specific branch using

git checkout origin/[branch]

I want to commit something to my specific branch origin/[branch] But when I am trying to push something using by

git push origin [branch]

I got this error

error: src refspec [branch] does not match any.
error: failed to push some refs to 'https://github.com/kkammo/yonseitree.git'

I tried to solve this problem but I can't find any solution... so plz help me T.T

Lightening answered 2/11, 2014 at 16:37 Comment(1)
Did you not get a big warning message about detached HEAD when you did your git checkout origin/[branch]Lias
E
44

A replicated question here, src refspec master does not match any when pushing commits in git

Try git show-ref to see what refs do you have. Is there refs/heads/[branch]?

You can try git push origin HEAD:[branch] as more local-reference-independent solution.

It works for me.

Elvyn answered 24/3, 2015 at 3:57 Comment(4)
"git show-ref" wasn't showing my branch, but after I performed "git push origin HEAD:[branch]", it showed up on the next "git show-ref" - thank you Luna!Wayzgoose
Seems to do the trick, upvoted but could you add some explanation on why does it solve the issue?Enlarger
should be marked as solution. Also would be nice to have explanationAdministrator
I have the same error. The reason is that I did not commit anything to the local repo. After committing, everything's going well.Chekiang
S
1

Below is your now branch:

* dev master remotes/origin/master

The new branch dev is created from master and have been done some commits.

Use the command below to push this new branch:

git push -u origin --tags HEAD:dev

After that, we check again:

* dev master remotes/origin/dev remotes/origin/master

That's OK for me.

Saltcellar answered 14/3, 2017 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.