Skip to content

Instantly share code, notes, and snippets.

@bnguyensn
Created April 1, 2025 09:42
Show Gist options
  • Save bnguyensn/05cecfcd4f1b50e9e51378de7b61e4ad to your computer and use it in GitHub Desktop.
Save bnguyensn/05cecfcd4f1b50e9e51378de7b61e4ad to your computer and use it in GitHub Desktop.
git fetch -p
for branch in $(git branch --format='%(refname:short)' | grep -v 'develop'); do
remote_branch=$(git for-each-ref --format='%(upstream:short)' refs/heads/$branch)
if [ -n "$remote_branch" ] && ! git show-ref --quiet "refs/remotes/$remote_branch"; 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