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.
If you are on Windows or another case-insensitive filesystem, and there are any capitalization change in the name, you need to use -M, otherwise, git will throw branch already exists error:
git branch -M <newname>
- 1How to Install Git on Ubuntu 18.04?
- 1Which is the right way to reflect already pushed changes to local branch?
- 1SVN vs Git: Which One Is Best For Your Needs
- 2How to 'git stash' an untracked file?
- 1How to undo git rm?
- 1How to make git commands shorter
- 1How to run symfony application with https in local environment
- 1How to change the most recent Git commit message?
- 1git add -A VS git add
- 1Is it possible to view a git log of commits of just one user?
- 2What does Git-blame do?