Create & update a major tag for your release using semantic-release (for example 'v2')
I am using this plugin in a GitLab CI/CD pipeline and recently got this error: ``` [11:49:44 AM] [semantic-release] › ✘ An error occurred while running semantic-release: Error: Command failed with exit code 1: git fetch --tags --update-head-ok [https://gitlab-ci-token:[secure]@gitlab.acme.com/my-group/my-project.git](https://gitlab-ci-token:%5Bsecure%[email protected]/my-group/my-project.git) +refs/heads/main:refs/heads/main From https://gitlab.acme.com/my-group/my-project ! [rejected] v1 -> v1 (would clobber existing tag) ``` This is because the default [Git strategy](https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy) was to use `git fetch` to get the repository, it then reused previous artifacts which caused this error to happen. If [the fetch function](https://github.com/semantic-release/semantic-release/blob/6e57047ecae906bf020edcf47fb9a3734da06f2b/lib/git.js#L105-L135) in semantic-release had fetched the tags with `--force` this would not have been a problem. Another solution is to make sure that the CI/CD pipeline always clones a fresh repository. In GitLab this is done by adding this to the job making the release: ```yaml variables: GIT_STRATEGY: clone ``` This may not be an issue for GitHub actions users, but in case others come across the same error this may at least be the root cause.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by mikaello and has received 3 comments.