In this next GIT code snippet post, we’ll show you how to delete local merged branches in GIT.

git branch --merged <branch> | grep -v "(^\*|<branch>)" | xargs git branch -d

git checkout master
git branch
# master
# patch-1
# patch-2

# Assuming `patch-1` is merged into master
git branch --merged master | grep -v "(^\*|master)" | xargs git branch -d

git branch
# master
# patch-2

Tags: git, git command line, git shell, git bash, git ssh, delete git, delete git branches, merged, grep, merge master, Version Control

CC BY 4.0 added intro and tags – 30 Seconds of Code