43

How you I change the connected commit on a github release? Release

I want to change it to an earlier commit, because I created the release afterwards (after some commits to release 0.9)

Zoker
  • 1,940
  • 4
  • 29
  • 51

1 Answers1

51

When you consider the GitHub API for creating a release, you see a release needs:

  • a tag
  • a commit referenced by that tag

So you need to move your tag (locally first, then push it to your GitHub repo)

git tag -f -a <tagname> [<commit> | <object>]
git push -f <reponame> refs/tags/<tagname>

Then see if that is enough for the release to be updated.
(See "How do you push a tag to a remote repository using Git?")

If not, you might have to delete that release, and recreate it on the same tag (which will refer to the new commit)

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • 1
    I did the first line before posting here, but it did not work. The second line fixed it :) – Zoker Jul 20 '14 at 13:33
  • how do you specify the commit id in the first command? My commit id is: `10a4ff2`. So what should my command be? `git tag -f -a v1.2.0 ...???...` – Parth Tamane Jan 29 '21 at 07:48
  • @ParthTamane Simply `git tag -f -a v1.2.0 10a4ff2`, as illustrated in https://git-scm.com/book/en/v2/Git-Basics-Tagging#_tagging_later – VonC Jan 29 '21 at 07:52
  • From https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git , use "git push origin " since "git push --tags" would push all tags and that isn't always the best option. – Sam Feb 04 '21 at 21:41
  • @Sam Good point, thank you. I have edited the answer accordingly. – VonC Feb 04 '21 at 21:43
  • @Sam Sure, I have edited the answer accordingly. You can also edit it directly: I will review and approve your edit. – VonC Feb 12 '21 at 19:25