You may take the following actions to rename a local Git branch:
1. Examine the Branch: Ensure that you are on the branch that you wish to rename before proceeding. If you need to, move to a different branch, as you are unable to rename the branch that is currently checked out.
git checkout old-branch
2. Rename the Branch: To rename the branch, use the -m option when running git branch.
git branch -m new-branch-name
Put the appropriate new name for the branch in lieu of new-branch-name.
3. Push the Renamed Branch to Remote (Optional): You should also edit the remote branch name if the branch has already been pushed to a remote repository.
git push origin -u new-branch-name
The renamed branch’s upstream branch is set using the -u option.
These actions result in the renaming of your local branch. Make sure to let your teammates know about any changes to the branch that have already been published to a remote repository and urge them to update their local repositories as well.