Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

How do I rename an existing branch in a Git repo?

I want the current branch to have a new name.

1 Answer

0 votes
by (50.2k points)

If you are currently on the branch which you need to rename it using:

git branch -m new_name 

Or else:

git branch -m old_name new_name 

To check the name changed or not you could use

git branch -a

This will show you the branch with a new name it means you have successfully changed the branch name in the local repo if you want to do that in remote repo then you could use:

git push origin: old_name

This will remove the old branch name

git push origin new_name

This will update the changes in the repo and uploads the file with the changed name or new name.

Browse Categories

...