semver
semver copied to clipboard
Gitlab CI/CD - `src refspec main does not match any`
When you push in Gitlab CI like git push origin main
you will get this error
error: src refspec main does not match any.
error: failed to push some refs to 'https://gitlab-ci-token/:[MASKED][email protected]/gc/packages.git'
Proposed solution
Push like this git push origin HEAD:main
then it works
More info here
Same happens to me in Azure DevOps. What i noticed is that pipelines (at least in Azure DevOps) by default checkout to detached HEAD and seems to haves no knowledge of other branches. What I did is that I added git fetch && git checkout to main branch before I run version command. I don't know if this is the best solution, but it's an easy one. In another project I am using semantic-release tool which had no problems with pushing changes back to designated branch. Hope this helps :)
Thanks @michalvadak for raising the issue. We'll have to dive into this.
Meanwhile, could you confirm that using baseBranch: 'HEAD:main'
works for you?
Thank you 🙏
baseBranch: 'HEAD:main'
works fine