How to rename a branch in Git

If you haven’t pushed your local branch to a remote branch in Git and you would like to rename your current local branch, you should proceed as follows :

Run the command:

git branch -m <newbranchname>                                [git rename current branch command]

Where -m refers to “move” operation.

If you are on a a case-insensitive file system like Windows, you would need to use -M as follows:

git branch -M <newname>

 

Answer due to Siride


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Nikolaus Oosterhof

Nikolaus has a degree in software development. He is passionate about gadgets with a screen, nostalgic for phones, a retired gamer and open source programmer. He likes also to write about macOS and Windows. design web pages and debug long programs!

Leave a Reply