Last Updated: January 02, 2018
· fluxsauce
E5529d996db3f33b95a95a28e7a1b923  1

Local Git cleanup of remotely deleted and merged branches

It's good to clean up every once and a while.

Make sure you're on the master branch.
git checkout master

Make sure you're up-to-date.
git pull

Update remote list of branches and remove remotely deleted branches.
git fetch --prune

Delete all merged branches from your local except master. Adjust as needed if have specific branches needed for your workflow!
git branch --merged | egrep -v "(^\*|master)" | xargs git branch -d

Clear your git stash; if you set it aside months ago, you probably don't need it there.
git stash clear

Say Thanks