Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (29.3k 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

closed

1 Answer

+5 votes
by (50.2k 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!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...