题
我在github.com与2个分支的公共存储库:master
和test
我创建了一个新的目录,本地和做的:
[ ] git clone git@github.com:{username}/{projectname}.git
然后创建一个新的命名my_test
分支
[ ] git branch my_test
和切换到它。
[ ] git checkout my_test
然后我用
合并它从我的公共仓库的我test
分支
[ ] git merge origin/test
和它导致了快进。
我做了一些改变,并承诺他们。
然后我试图本地my_test
分支推送到在github上公众test
分支
[ ] git push git@github.com:{username}/{projectname}.git test
,但我得到这个错误:
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
我在做什么错了?
解决方案
也许尝试:
git push git@github.com:{username}/{projectname}.git HEAD:test
这命令行上的最后一个参数的格式是一个的Refspec 其是源REF后面跟着冒号,然后目的地REF。你也可以用你的本地分支名(my_test
),而不是头肯定你推正确的分支。
有 git push
文档具有更详细地对这个参数。
其他提示
此外,你并不需要你想推每次都输入了整个URL。当您运行克隆的git保存的网址为“原点”,这就是为什么你可以运行类似“合并产地/测试” - 这意味着你的“出身”服务器上的“测试”分支。所以,最简单的方式推送到你的服务器在这种情况下将是:
git push origin my_test:test
这将推动当地的“my_test”分支“测试”分支的“出身”的服务器上。如果你有一个名为您当地的分行一样的服务器上的分支,然后结肠不是neccesary,你可以简单地做:
git push origin test
如果您尝试推到一个新的存储库,而不必首先犯了什么这个错误也出现。尝试:
git add -A
git commit -am 'Initial commit'
和然后再次尝试推。
我想在这里你将需要设立分公司跟踪。请运行以下,以使跟踪
git branch --track my_test origin/my_test
要测试
git push -u origin my_test
git pull origin my_test
您需要确保您的本地资源库具有相同的名称,你试图把你的远程存储库。
首先,使用GIT中分支-m“测试”,使“my_test”将是“测试”改变存储库。 第二,只是GIT中推原点测试
不隶属于 StackOverflow