Search code examples
gitgithubrelease

Change connected commit on release github


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)


Solution

  • 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>]
    # or, to avoid an editor
    git tag -m "tag message" -f -a <tagname> [<commit> | <object>]
    
    git push -f <remotename> refs/tags/<tagname>
    

    for Example:

    git tag -m "moving tag to new commit" -f -a my_tag [commit hash]
    git push -f origin refs/tags/my_tag
    

    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)


    After doing this, if you get an error would clobber existing tag, then you need to sync local tags with remote using git fetch --tags -f and the push new commits.