Git

1. Git Cleaning

# clean local branches
git branch -d $(git branch --merged=master | grep -v master)
# clean local remote branches
git fetch --prune

Reference: here

2. Rename Local Branches

Say you want to rename the branch old-name to new-name locally.

git checkout old-name
git branch -m new-name
# -m: move/rename a branch and its reflog

3. Rename Local & Remote Branches

Say you want to rename the branch old-name to new-name locally, then push it to remote and delete the original remote brach.

git checkout old-name
git branch -m new-name
git push origin :old-name
# <+><source>:<destination>  
# git push origin :old-name means make origin old-name empty
git push --set-upstream origin new-name