How to rename a local Git branch?
Use git branch -m (move).
Terminal output
$ git branch -m old-name new-name
$ git branch
* main
new-name
To rename the branch you are currently on, give only the new name: git branch -m new-name.
If the branch is already pushed, rename it on the remote too: push the new name and delete the old one.
git push origin -u new-name
git push origin --delete old-name
Learn more about the similar topics:
| Tutorials |
|---|
| Git Branch |
| Git Checkout and Switch |
| Git Merge |
| Git Merge Conflict |
| Git Rebase |
| Git Cherry Pick |
| Git Branching Strategy |