If you've been waiting to rename your default branch from master to main , we now recommend doing so using this feature. When a branch is renamed: Open pull requests and draft releases targeting the renamed branch will be retargeted automatically.
About renaming branches When you rename a branch on GitHub.com, any URLs that contain the old branch name are automatically redirected to the equivalent URL for the renamed branch.
"Renaming" a remote branch in git, as indicated by the link you provided, is really just deleting a branch, followed by pushing a new one with the same commit hash but a new name. If you have a pull request open for branch patch-1, when you delete that branch, the pull request will be closed.
So, no you can't rename the branch with a pull request open without deleting the branch and removing the pull request. However, there's nothing stopping you from doing that, pushing a new branch with a new name, and creating a new pull request.
Check out this answer
No
The name of a remote branch (constituting a PR) needed to change because the build system needed the branch's name that ends with the ticket ID. However, the PR was opened prior to official ticket creation (from specs) and had contained valuable discussion. The described approach was the only way to make build system work, and also not lose any information (although there was an extra step in tracking it).
Yes for the target branch. Since Jan. 2021
See "Support for renaming an existing branch".
Details in "How do I rename branch on the GitHub website?".
From github/renaming
, this will re-target any open pull requests.
As charlie Harding adds in the comments:
- "Will update 4 pull requests targeting this branch" means it will change the branch into which a pull request would like to merge.
This was previously possible through those PRs’ pages anyway.- Trying to rename a branch which is the source of the PR, on the other hand, will result in that PR being closed ("Will close 1 open pull request for this branch.").
As Michael Freidgeim adds in the comments:
There is a request to support renaming base branch in github.community.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With