How to rename a branch you already pushed to remote?

How to rename a branch? #dev #git #workflow #coding

Abdallah Yashir
2 min readMar 7


Let’s say you start working on a task and create a branch with the same name. But as you progress further, you realise that the work itself doesn’t describe the task name or the nature of work changes in between. However, you have already pushed your changes on remote.

How do you rename the branch both locally and remotely?

  1. git checkout <old_name>
  2. git branch -m <new_name>
  3. git push origin -u <new_name>
  4. git push origin — delete <old_name>


There are also different ways of achieving the same outcome. For example, this gist does it in fewer lines.

git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote


There are also GUI tools that help you do the same in a few clicks.



Abdallah Yashir

Senior Software Developer, Writer, Amateur Photographer, Reader