#!/usr/bin/env bash # delete all branches without upstream while read branch; do upstream=$(git rev-parse --abbrev-ref $branch@{upstream} 2>/dev/null) if [[ $? == 0 ]]; then # upstream exists echo $branch tracks $upstream else # no upstream --> delete git branch -d $branch fi done < <(git for-each-ref --format='%(refname:short)' refs/heads)
标签:Git,branches,without,branch,upstream,delete From: https://www.cnblogs.com/dissipate/p/16874799.html