Situational guide to Git for new engineers - rename branch

Situation: You realise your branch name is wrong and you already made a lot of local commits

Sometimes you have done some work and committed it locally but not yet pushed it to remote. Then as you are about to push changes you realise you have spelling error on your branch or other naming issue such as task id not matching your Jira ticket.

Rename local branch command:

git branch -m oldBranchName newBranchName

What does command do

This commands simply takes old name and new name. It will instantly rename your local branch.