

To rename a local branch, you can use the git-branch command with the -m or -M option.
#Git branch rename how to#
Quick oneliner for deleting old branch and creating a new one with same content is: git push /:refs/heads/ : This post will discuss how to rename a Git branch locally and remotely.


Then delete old branch which will also close the old pull-request. If you are trying to rename it on github, then you need to remove it from the local repo, rm filename. You need first to rename the local branch push the new branch to the server delete the old branch from your repository. If you are using GitHub, from repo go to Settings > Branches > Default Branch and. I can say only for Github that there's no option to rename a branch in their interface nor option to change "compare" branch in a pull request.īest solution (for Github) is probably to create a new branch and new pull request, post a comment to old pull-request that it was "closed in favor of #NEW" and "continuation of #OLD" to new one. This repository is our up-to-date guidance on how and when to rename your default branch. We're committed to making the renaming process as seamless as possible for project maintainers and all of their contributors. Depending on where you have pull request open (you don't mention whether is it Github, Gitlab, Phabricator or something else) you might have some options given to you by tool operating on repository locally where pull request exists. GitHub is gradually renaming the default branch of our own repositories from master to main. Renaming a remote branch in Git is really just creating a new branch with same commits and new name and deleting old branch.
