Skip to content

Instantly share code, notes, and snippets.

@gigamonkey
Last active October 16, 2022 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigamonkey/1bf0678923703e6da39d8c3ddb80c6e6 to your computer and use it in GitHub Desktop.
Save gigamonkey/1bf0678923703e6da39d8c3ddb80c6e6 to your computer and use it in GitHub Desktop.
Script to clean up local branches that have been merged to the current branch.
#!/bin/bash
# Script to clean up local branches that have been merged to the current branch.
# Normally you'd run this while on main.
set -euo pipefail
current=$(git branch --show-current)
git branch --merged | cut -c 3- | while read -r branch; do
if [ "$branch" != "$current" ]; then
git branch -d "$branch"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment