Renaming

Current branch

git branch -m new-name

Renames the current branch. -m is short for --move; see the git-branch manual.

Another branch

git branch -m old-name new-name

Renames a branch without checking it out. See the git-branch manual.

Push the new name

git push -u origin new-name

Publishes the new branch name. Creates the remote branch and sets its upstream; -u is short for --set-upstream. See the git-push manual.

Delete the old name

git push origin --delete old-name

Deletes the old remote branch. Other clones keep their own local old-name; see the git-push manual.

0 Comments for this cheatsheet. Write yours!