Renaming a branch in Git

Published on May 23, 2016

We are all super fast keyboard wizards. Our words per minute almost surpasses our typos per minute. Almost.

What sucks is when you have a typo with your git branch name, am I right? It is totally lame.

You are about to work on the best feature ever and then you flub up the branch name.

$ git checkout -b best-featrue-evre

SONUVA! But have no fear, you can easily rename your branch by moving (aka renaming) it into another branch.

$ git branch -m best-featrue-evre best-feature-ever

The git command works like this:

$ git branch -m <oldname> <newname>

You could also have renamed the branch if it was your current branch using:

$ git branch -m best-feature-ever

And that works like this:

$ git branch -m <newname>

So probably don’t have any more excuses for having typos in your git branches… well beyond normal programmer laziness. #wehaveallbeentherebefore