git: rename a branch [locally and remotely]

It happens to me quite a lot: I create a branch and then want to rename it to a more specific/correct name.
If that branch has already been pushed to a remote, this operation is a bit trickier than the usual renaming.

I've found this nice gist from lttlrck and thought I'd share it:

Enjoy!