File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 44
55git fetch --prune & > /dev/null
66
7- # Use `git for-each-ref` to safely handle branch names with spaces and avoid
8- # parsing the output of `git branch`.
9- git for-each-ref --format=' %(refname:short)\t%(upstream:short)' refs/heads |
10- while IFS=$' \t ' read -r branch upstream; do
11- if [ -n " $upstream " ] && ! git show-ref --quiet " refs/remotes/$upstream " ; then
12- echo " Deleting branch '$branch '"
13- git branch -D " $branch "
7+ for branch in $( git branch -vv | grep -o -E ' ^[\* ]+\S+' | tr -d ' * ' ) ; do
8+ upstream=$( git rev-parse --abbrev-ref --symbolic-full-name " ${branch} @{upstream}" 2> /dev/null)
9+ if [ -n " ${upstream} " ]; then
10+ if ! git show-ref --quiet " refs/remotes/${upstream} " ; then
11+ echo " Deleting branch '${branch} '"
12+ git branch -D " ${branch} "
1413 fi
15- done
14+ fi
15+ done
You can’t perform that action at this time.
0 commit comments