jscutlery / semver

Nx plugin to automate semantic versioning and CHANGELOG generation.
MIT License
719 stars 83 forks source link

Gitlab CI/CD - `src refspec main does not match any` #709

Open michalvadak opened 1 year ago

michalvadak commented 1 year ago

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]glpat-@gitlab.geekcoders.cz/gc/packages.git'

Proposed solution Push like this git push origin HEAD:main then it works

More info here

gregorsintic commented 1 year ago

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 :)

michalvadak commented 1 year ago

Yeah, the semantic-release is actually using the git push origin HEAD:main

Link

yjaaidi commented 1 year ago

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 🙏

michalvadak commented 1 year ago

baseBranch: 'HEAD:main' works fine