Created
July 14, 2022 12:29
-
-
Save stand-sure/5d160e8932321619ae3e249d8d754d40 to your computer and use it in GitHub Desktop.
Git delete merged branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
branchName=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | |
git checkout "$branchName" \ | |
| git branch --merged \ | |
| grep -E --invert-match "(^\*|master|main|dev)" \ | |
| xargs git branch --delete \ | |
&& git remote prune origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment