批量删除本地Git合并过的分支

#!/bin/bash

echo '' > tmp.txt && git pull && git branch > tmp.txt

branchs=$(cat tmp.txt | awk '{if (NF == 1) print $1}')

for branch in $branchs;do
  if [ $branch = "*" ] || [ $branch = "master" ] || [ $branch = 'dev' ] || [ $branch = 'release-qa' ];
  then
    echo -e "\033[32m$branch\033[0m Skip"
  else
    git branch -d $branch > /dev/null 2>&1 && echo -e "\033[34m$branch\033[0m 删除成功" || echo -e "\033[31m$branch\033[0m 分支删除失败"
  fi
done

rm tmp.txt > /dev/null 2>&1

你可能感兴趣的:(批量删除本地Git合并过的分支)