我按照下面的文章将gitlab存储库代码推送到Google云源存储库,但是此命令出现错误
git push -f google master
error: src refspec master does not match any.
error: failed to push some refs to 'https://source.developers.google.com/p/project/r/test/'
随后的文章: https://medium.com/@bamnet/cloud-source-repositories-gitlab-2fdcf1a8e50c
有什么,我做错了??关于如何避免此错误消息的任何想法?
答案 0 :(得分:1)
src refspec master does not match any
问题是您正在关注的文章的日期:2018年8月。
自那时以来,GitLab Runner发生了变化,更确切地说是在2019年5月。
此问题在2019年5月的this thread中进行了描述:
由于我们使用refspec来克隆/获取存储库,因此我们签出特定的提交而不签出特定的分支。
当脚本执行git push master
时,找不到分支,因此git不知道要推送什么。
那是因为在GitLab方面,MR 1203:
基本上,GitLab CE / EE将refspecs参数发送到GitLab Runner
gitlab-org/gitlab-foss
app/presenters/ci/build_runner_presenter.rb
:此参数用于GitLab Runners中以从远程存储库中获取分支/标记引用。之所以引入此更改,是因为我们希望GitLab Rails可以利用规范来进行issue 7380 "Combined ref pipelines (source+target branch)"的使用,
git clone $URL
或mkdir $REPO_DIR && git remote add origin $URL && git fetch +refs/heads/branch_name:refs/remotes/origin/branch_name
之间应该没有太大的区别。
实际上,新行为已在我们的开发项目中运行 https://gitlab.com/gitlab-org/gitlab-ce/pipelines,到目前为止没有问题。
Issue 4097当时已打开
解决方法
当您要将其推送到另一个遥控器时,请使用HEAD。
deploy:
stage: deploy
script:
- git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/<project>.git
- git push -f heroku HEAD:master
所以不要按master
。按下HEAD。
OP Adam使用另一种解决方法并添加:
before_script:
- git checkout master