Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
Last active March 19, 2024 04:54
Show Gist options
  • Save suzumura-ss/b0400cfddbaa42def987908f073e6b4a to your computer and use it in GitHub Desktop.
Save suzumura-ss/b0400cfddbaa42def987908f073e6b4a to your computer and use it in GitHub Desktop.
remove "gone" branches
#!/bin/bash
CURRENT_BRANCH=$(git branch --show-current)
BRANCHES=$(git branch --format="%(refname:short) %(upstream:track)" | grep "\[gone\]" | awk '{ print $1 }' | grep -v $CURRENT_BRANCH)
[[ -n "$BRANCHES" ]] && git branch -D $BRANCHES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment