Twitter icon LinkedIn Icon Github Icon Stackoverflow Icon

Rename a Local Git Branch

By: Roger Creasy

Naming thigs is hard. On a few occasions I have named a Git branch, then decided a different name would be better / more descriptive. Recently, I was working on a branch for a project, and we decided to go a different direction. My branch had the perfect name for the feature I was working on; I didn't want to loose my work. So, I couldn't just delete the branch. I renamed the branch, making the name available for a new branch.

To rename the branch you are currently on, enter the following:

git branch -m newBranchName

To rename a branch other than the one you are on:

git branch -m oldBranchName newBranchName

Thanks for reading. I hope this post is helpful.


Publication Date: 2019-10-11 15:03:49