在“git push”时出错到github [英] Error when "git push" to github
问题描述
我在github.com上有两个分支的公共仓库: master
和 test
。
我在本地创建了一个新目录并执行:
[] git clone git @ github.com:{username}/{projectname}.git
然后我创建了一个名为 my_test
with
[] git branch my_test
并切换到它。
[] git checkout my_test
然后我将它从我公共存储库的 test
分支中与 $ b <$ p $合并p> [] git merge origin / test
向前。
我做了一些更改并付诸实践。
然后我尝试用
my_test
分支推送到github上的public test
分支。 > [] git push git@github.com:{username} / {projectname} .git测试
$ c $
错误:src refspec测试不匹配任何。
致命:远程端意外挂起
错误:未能将一些文件推送到'git@github.com:{username} / {projectname} .git
我做错了什么? 也许试试:
git push git@github.com:{username} / {projectname} .git HEAD:test
该命令行上最后一个参数的格式是 refspec ,它是一个源ref后跟一个冒号,然后是目的地ref。您还可以使用您的本地分行名称( my_test
)而不是HEAD来确定您正在推送正确的分行。
git的文档push
有关于此参数的更多详细信息。
I have a public repository at github.com with 2 branches : master
and test
.
I created a new directory locally and did:
[ ] git clone git@github.com:{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 git@github.com:{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 'git@github.com:{username}/{projectname}.git
What am I doing wrong ?
解决方案 Perhaps try:
git push git@github.com:{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.
这篇关于在“git push”时出错到github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!