Help, I gave my branch the wrong name
Rename a branch locally, and on the remote too if you already pushed it.
The fix
git branch -m feature/loginRenames the branch you are on. For another branch:
git branch -m old-name new-name.
feature/login is an example. Replace it with your own.
git branch -m feature/loginRename it locally first.
git push -u origin feature/loginPushes the new name and makes it the upstream, so plain
git pushworks again.git push origin --delete feature/lgoinDeletes the old name on the remote. On GitHub this closes open pull requests from it, so with an open PR rename the branch on GitHub instead.
feature/login is an example. Replace it with your own.
git branch -m feature/loginWhy this works
Renaming only changes the label. Commits and history stay the same. On the remote there is no rename, so you push the new name and delete the old one. The -u matters: after the rename, the branch still tracks the old remote name, and plain git push would refuse until you point it at the new one.