How do I rename a local Git branch?
I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.
How can I rename a local branch which hasn't been pushed to a remote branch?
If you want to rename a branch while pointed to any branch, do:
git branch -m <oldname> <newname>
If you want to rename the current branch, you can do:
git branch -m <newname>
A way to remember this, is -m
is for "move" (or mv
), which is how you rename files.
git branch -m old_branch_name new_branch_name
The above command will change your branch name, but you have to be very careful using the renamed branch, because it will still refer to the old upstream branch associated with it, if any.
If you want to push some changes into master after your local branch is renamed into new_branch_name (example name):
git push origin new_branch_name:master
(now changes will go to master branch but your local branch name is new_branch_name)
For more details, see "How to rename your local branch name in Git."
重命名您的当前分支:
git branch -m <newname>
链接地址: http://www.djcxy.com/p/34.html
上一篇: var functionName = function(){} vs function functionName(){}
下一篇: 我如何重命名本地Git分支?