The git branch command lets you rename a branch. To rename a branch, run git branch -m <old> <new>. “old” is the name of the branch you want to rename and “new” is the new name for the branch.
the feature move
exists to rename the branch locally
git branch --move <old_name> <new_name>
but to push it, you must delete the old and push the new
git checkout <new_name>
git push origin [--set-upstream] <new_name>
git push origin --delete <old_name>
--set-upstream
is optional, it configure the new local branch to track the pushed one
move locally (--move) :
git branch -m <old_name> <new_name>
push new branch (--set-upstream, optional) :
git push origin [-u] <new_name>
delete (--delete) :
git push origin -d <old_name>
Thanks to torek's comment:
Worth mentioning, by the way, is that you should
The reason for #1 is that those users will need to adjust.
The reason for #2 is mainly just efficiency: it avoids having to re-copy objects to an upstream repo that drops commits on branch deletion (most bare repositories do that, and most repositories that accept pushes are bare)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With