How to Rename A Branch in GitHub Desktop?

Hello GitHub Community,

I need to rename a branch in GitHub. I prefer doing it through the remote and not Desktop, as when I try on Desktop it gives me this message:

This branch is tracking branch name, and renaming this branch will not change the name on the remote.

Changing its name on the remote is exactly what I want to do.

Thank you

If your remote repository is on GitHub, you can rename the branch over the web interface: Go to the branches list for the repository and click on the pencil symbol on the right.

If you don’t want to do that or your repository is hosted somewhere else and that place doesn’t offer renaming, you can push to a specific remote branch name, with or without renaming your local branch. I don’t know if GitHub Desktop supports this, but git push lets you specify local and remote ref names separately (though the default is to use the same for both). For example,

git push origin HEAD:my-branch

pushes the current HEAD to the remote branch my-branch. The documentation has a detailed description of the <refspec> format, and examples further down.

1 Like

Thank you, this is exactly what I needed, and was able to easily change the name of my branch from the branch list.

1 Like