How to rename a branch in Git

Renaming Git branches is a common task when you need to correct typos, follow naming conventions, or better describe the branch purpose in your development workflow. As the creator of CoreUI, a widely used open-source UI library, I’ve managed thousands of Git branches across multiple repositories and enterprise projects. From my 25 years of experience in software development and version control, the most straightforward approach is to use the git branch -m command for local branch renaming. This method provides clean branch management without losing commit history.

Use git branch -m new-name to rename the current branch or git branch -m old-name new-name to rename any branch.

# Rename the current branch
git branch -m new-feature-name

# Rename a specific branch (not currently checked out)
git branch -m old-feature-name new-feature-name

# If you need to rename a branch that's been pushed to remote
git branch -m old-name new-name
git push origin -u new-name
git push origin --delete old-name

The -m flag stands for “move” and renames the branch locally. If you’re on the branch you want to rename, simply provide the new name. If you want to rename a different branch, specify both the old and new names. For branches that have been pushed to a remote repository, you’ll need to push the renamed branch and delete the old one from the remote. The -u flag sets the upstream tracking for the new branch name.

This is the same branch management approach we use in CoreUI development to maintain clean and descriptive branch naming across our repositories. Always coordinate with your team before renaming shared branches to avoid confusion in collaborative development workflows.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author