Rename a branch
My branch has the wrong name.
The problem
My branch has the wrong name.
How the practice repository looked before
## fetaure
9a23fe0 First
The fix
Check the result
* feature main
Why this works
git branch -m <new> renames the branch you are on. To rename another branch, give both names: git branch -m old new.
If this is not quite your case
To push the new name and remove the old one on the remote, run git push origin -u feature and then git push origin --delete fetaure (use your real names). If the branch is the default branch on a hosting service, rename it in the service settings first, so that its pages do not break.
Be careful: If the old name was pushed, the new name is a different branch on the remote. Push the new name and delete the old one there.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.