YouTube Icon

Code Playground.

How To Rename a Local and Remote Git Branch

CFG

How To Rename a Local and Remote Git Branch

You are teaming up on a task with a gathering of individuals, and you have characterized a naming show for git branches. You made another branch , pushed the progressions to the far off vault, and understood that your branch name was mistaken. 

Fortunately, Git permits you to rename the branch effectively utilizing the git branch - m order. 

This guide discloses how to rename neighborhood and far off Git branches. 

Renaming Git Branch

Follow the means underneath to rename a Local and Remote Git Branch: 

Start by changing to the neighborhood office which you need to rename: 

git checkout <old_name>

Rename the neighborhood office by composing: 

git branch -m <new_name>

Now, you have renamed the neighborhood office. 

On the off chance that you've just pushed the <old_name> branch to the far off vault , play out the following stages to rename the far off branch. 

Push the <new_name> neighborhood office and reset the upstream branch: 

git push origin -u <new_name>

Erase the <old_name> far off branch: 

git push origin --delete <old_name>

That is it. You have effectively renamed the neighborhood and far off Git branch. 

Conclusion

Branches are important for the product improvement cycle and one of the most impressive highlights in Git. Branches are basically pointers to a certain submit. 

Renaming a neighborhood Git Branch involves running a solitary order. Anyway you can't straightforwardly rename a far off branch, you need to push the renamed neighborhood office and erase the branch with the old name. 

On the off chance that you hit an issue or have criticism, leave a remark underneath.




CFG