TIL: How To Rename a Git Branch

There are times where you might want to rename a local branch you're working on for whatever reason. If you haven't already pushed the branch up to Github, it's as simple as the following command:

git branch -m old_branch_name new_branch_name  



If you've already pushed this branch up to Github, there's a few more steps you have to take. After renaming your branch, delete the old one from your remote repository:

git push origin :old_branch_name  



Then push the new branch up to your remote repository:

git push origin -u new_branch