+4 votes
1 view
in Devops and Agile by (28.1k points)
edited by

I don't want to rename a remote branch, as described in the Rename master branch for both local and remote Git repositories.

How can I rename a local branch which hasn't been pushed to a remote branch?

In case you need to rename remote branch as well:
How do I rename both a Git local and remote branch name

1 Answer

+5 votes
by (48k points)
edited by
 
Best answer

If you need to rename your local git branch 

$git branch -m<old-name><new-name>

this command is used for changing the name of branches while it is pointed to another branch.

If you need to change the name of a remote branch then 

$git branch -m<new-name>

this will be handy to use when you need to rename your remote branch.

There is one more command

$git push origin <new-branch-name>: master

this command is used to pushing the changes to the master after your local branch is re-named.

Note: Changes will go to the master branch but the local branch name remains a modified name (ie:-new-branch-name).

For more commands like this please go through the following tutorial that will help you understand the git

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...