Skip to main content

How to rename a Git branch

Renaming git branch in different VCS providers

Written by Mykyta Nechepurenko

Why you might need to do this

You might need to rename a branch to fix a typo, follow a naming convention, or shorten a name that's too long. A branch name that's too long can even cause an error like this:


Along with this error in the logs:

Sorry, refs longer than 255 bytes are not allowed.

Why this happens

Git limits branch names to 255 bytes. If your feature branch name is too long, your Git provider (like GitHub, GitLab, Bitbucket, or Azure DevOps) rejects the pull request before Gearset can create it. This is a limit set by Git and your Git provider.


How to rename a Git branch

Currently, only Github allows to rename the branch directly in UI.


To do so in Github, navigate to your repo and click Branches:

And then ••• on your feature, Rename branch:


For other VCS providers, the easiest option to rename would be to re-create your feature branch by deleting it and creating a new one. Alternative instructions would be to rename it through Git CLI with these commands:

git checkout old-branch-name
git branch -m new-branch-name
git push origin new-branch-name
git push origin --delete old-branch-name


If you have any further questions, please reach out in our in-app chat!

Did this answer your question?