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 wh
To rename a branch locally:
git branch -m [old-branch] [new-branch]
Now you'll have to propagate these changes on your remote server as well.
To push changes of the deleted old branch:
git push origin :[old-branch]
To push changes of creation of new branch:
git push origin [new-branch]
If you are willing to use SourceTree (which I strongly recommend), you can right click your branch and chose 'Rename'.
If it is your current branch, just do
git branch -m new_name
If it is another branch you want to rename
git branch -m old_name new_name
- If your branch was pushed, then after renaming you need to delete it from the remote Git repository and ask your new local to track a new remote branch:
git push origin :old_name
git push --set-upstream origin new_name
Since you do not want to push the branch to a remote server, this example will be useful:
Let's say you have an existing branch called "my-hot-feature," and you want to rename it to "feature-15."
First, you want to change your local branch. This couldn't be easier:
git branch -m my-hot-feature feature-15
For more information, you can visit Locally and Remotely Renaming a Branch in Git.
Here are three steps: A command that you can call inside your terminal and change branch name.
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
If you need more: step-by-step, How To Change Git Branch Name is a good article about that.
A simple way to do it:
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
For more, see this.