Using Terminal or command prompt
To rename a Git branch, you can use the git branch
command with the -m
option and the new branch name.
- To rename the current branch, use
git branch -m new-branch-name
- To rename a specific branch, use
git branch -m old-branch-name new-branch-name
- To propagate the change to a remote, use
git push origin -u new-branch-name
andgit push origin --delete old-branch-name
- To verify the renaming, use
git branch -a
orgit branch
If you're using Windows and want to change only the capitalization in the branch name, use -M
instead of -m
.
Using IntelliJ IDEA
You can also rename a branch in IntelliJ IDEA by:
- Selecting the branch you want to rename in the Branches popup or pane
- Choosing Rename
- Changing the branch name in the dialog
Above changes are verified on terminal.