Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

Error when "git push" to github

I have a public repository at github.com with 2 branches : master and test.

I created a new directory locally and did:

[ ] git clone [email protected]:{username}/{projectname}.git

Then I created a new branch named my_test with

[ ] git branch my_test

and switched to it.

[ ] git checkout my_test

Then I merged it from my test branch of my public repository with

[ ] git merge origin/test

and it resulted in a fast forward.

I made some changes and committed them. Then I tried to push the local my_test branch to the public test branch at github with

[ ] git push [email protected]:{username}/{projectname}.git test 

but I got this error:

error: src refspec test does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:{username}/{projectname}.git

What am I doing wrong ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Perhaps try:

git push [email protected]:{username}/{projectname}.git HEAD:test

The format of the last parameter on that command line is a refspec which is a source ref followed by a colon and then the destination ref. You can also use your local branch name (my_test) instead of HEAD to be certain you're pushing the correct branch.

The documentation for git push has more detail on this parameter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...