git branch rename | local and remote

preview_player
Показать описание
Did you mistakenly give a wrong branch name? Do you want to give a meaningful name using git commands? Yes, Then you are at the perfect place. In this article, we will show how to rename the Git branch both locally and remotely. Let’s just jump into it.

Rename Git Branch
01 Renaming a Local Git Branch
CASE 1: If you are on a current branch and you want to change the current branch name then run the following command:

git branch -m new-branch-name

The -m flag is an abbreviated form of --move, you can use either -m or --move.

You can also use the capital -M flag which means --move --force, which allows you to forcefully rename even if the branch already exists. So the existing branch will be overridden by it.


CASE 2: If you are on a different branch and you want to change any other branch name then run the following command:

git branch -m old-branch-name new-branch-name

02 Renaming a Remote Git Branch
If you’ve already pushed the Git branch to the remote repository then you can perform the following steps to rename a remote branch.

1. Delete the branch with the old name on the remote repository:

git push origin --delete old-branch-name
2. Finally, push the branch with the correct name:

git push origin :old-branch-name new-branch-name
That’s it. You have successfully renamed both local and remote Git branches.

-------
Keywords:
git branch rename
git rename branch
github rename branch
how to rename a git branch
github rename master branch
github rename remote branch
Рекомендации по теме
Комментарии
Автор

Why u wrote Remote if u dont want to tell that. Wastage of time !!!

chiragcode
Автор

do you have a group? I want to ask you something bro

rapiuljr
Автор

Hi, is possible you make an colab notebook to give tesla t4 every time ? like you did with tesla p100, I'm getting k80 every time.

taarix