How do I rename an existing branch in a Git repo?
I want the current branch to have a new name.
Assuming you're currently on the branch you want to rename:
git branch -m newname
This is documented in the manual for git-branch
, which you can view using
man git-branch
or
git help branch
Specifically, the command is
git branch (-m | -M) []
where the parameters are:
The name of an existing branch to rename.
The new name for an existing branch. The same restrictions as for apply.
is optional, if you want to rename the current branch.