简体   繁体   中英

How to change target branch of a release in GitHub?

I recently released a private repository but while releasing I made the mistake of releasing it using develop branch as target branch. Now i want that release to target master branch and not develop.

How to change the target branch to master?
Note: When i do edit, the option to change target branch appears for a second and then disappears.

Do i need to create a new branch for this?

I agree with @parsenz that there is no way to do this on GitHub (as of Enterprise v2.1). You will have to delete and recreate. I'm no git expert but here are the steps I followed to "move" a release from one branch to another on GitHub:

In GitHub (web UI):

  1. get a copy of the release and commit hash (usually from the pull request)
  2. delete the release from GitHub UI

Then in git bash:

  1. git push --delete origin <tag_name> // deletes remote tag
  2. git tag -d <tag_name> // deletes local tag
  3. git checkout <commit_hash>
  4. git tag <tag_name>
  5. git push origin <tag_name>
  6. [optional] git checkout <branch_name> (to go back to your previous branch)

Back in GitHub:

  1. recreate the release using the same tag on GitHub UI

Note: this normally happens because the release was created against the wrong branch. You can set a default branch for a GitHub repository in the repository settings (tools icon in the right tabs navigation).

I don't think you can on Github. You have to delete the release and recreate it. I solved this by entering the following in my console:

git push origin :refs/tags/{old_tag_name}

And then recreate the release

git pull --tags # Get all releases
commit=$(git rev-parse my-awesome-branch) # Get commit hash
echo $commit > .git/refs/tags/my-awesome-tag # Change target commit
git push --tags --force # Update tags on GitHub

Here my-awesome-branch and my-awesome-tag are the branch you want to target and tag you want to update respectively

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM