How to rename a local and remote git branch?

You can use git branch -m command to rename a local git branch. To rename a remote git branch, you first need to delete the existing branch and create the new branch.

Warning: Do not execute any command in your remote repository without being fully aware of the implications.

Create a new local git repository:

Add some changes and commit:

Add a remote git repository to your local repository:

Create a new local and remote git barnch:

Rename a local git branch name:

Rename a remote git branch name:

Delete your local and remote git repository