Created
April 22, 2025 14:00
-
-
Save FBen3/06c50b630fbf7b01d6ea564fc1df1534 to your computer and use it in GitHub Desktop.
git-branch-cleanup
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/sh | |
set -euo pipefail | |
git fetch --prune | |
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D | |
git branch --merged | grep -vE '^\*|main|master|develop' | xargs git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be aliased to a custom git command. This script cleans up you local branches:
main
,master
,develop
, or the currently checked-out branch)