I have many Git branches. How do I delete branches which have already been merged? Is there an easy way to delete them all instead of deleting them one by one?
You'll want to exclude the master
& develop
branches from those commands.
Local git clear:
git branch --merged | grep -v '\*\|master\|develop' | xargs -n 1 git branch -d
Remote git clear:
git branch -r --merged | grep -v '\*\|master\|develop' | sed 's/origin\///' | xargs -n 1 git push --delete origin
Sync local registry of remote branches:
git fetch -p