From 804fc2a943945ac77c79dfd9b13301feeda27c60 Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Sat, 8 Feb 2020 11:03:48 -0800 Subject: [PATCH] docs(Troubleshooting): release not found in prereleases branch (e.g. `beta`) after rebase on `master`) (#1444) --- docs/support/troubleshooting.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/support/troubleshooting.md b/docs/support/troubleshooting.md index 75e7aafa..26fb1855 100644 --- a/docs/support/troubleshooting.md +++ b/docs/support/troubleshooting.md @@ -54,3 +54,16 @@ $ git branch --contains $ git tag -d $ git push origin :refs/tags/ ``` + +## release not found release branch after `git push --force` + +**semantic-release** is using both [git tags](https://git-scm.com/docs/git-tag) and [git notes](https://git-scm.com/docs/git-notes) to store information about which releases happened in which branch. + +After a git history rewrite due to a `git push --force`, the git tags and notes referencing the commits that were rewritten are lost. + +To recover from that situation, do the following: + +1. Delete the tag(s) for the release(s) that have been lost from the git history. You can delete each tag from remote using `git push origin :[TAG NAME]`, e.g. `git push origin :v2.0.0-beta.1`. You can delete tags locally using `git tag -d [TAG NAME]`, e.g. `git tag -d v2.0.0-beta.1`. +2. Re-create the tags locally: `git tag [TAG NAME] [COMMIT HASH]`, where `[COMMIT HASH]` is the new commit that created the release for the lost tag. E.g. `git tag v2.0.0-beta.1 abcdef0` +3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v3.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}' +4. Push the local notes: `git push --force origin refs/notes/semantic-release`. The `--force` is needed after the rebase. Be careful.