Subversion Repositories MK-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
#!/usr/bin/env bash
2
#
3
# mfclean
4
#
5
# Prune all your merged branches and any branches whose remotes are gone
6
# Great way to clean up your branches after messing around a lot
7
#
8
 
9
KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
10
 
11
echo "Fetching latest upstream and origin..."
12
git fetch upstream
13
git fetch origin
14
echo
15
 
16
echo "Pruning Merged Branches..."
17
git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d
18
echo
19
 
20
echo "Pruning Remotely-deleted Branches..."
21
git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D
22
echo
23
 
24
# List fork branches that don't match local branches
25
echo "You may want to remove (or checkout) these refs..."
26
comm -23 \
27
  <(git branch --all | sed 's/^[\* ] //' | grep origin/ | grep -v "\->" | awk '{ print $1; }' | sed 's/remotes\/origin\///') \
28
  <(git branch --all | sed 's/^[\* ] //' | grep -v remotes/ | awk '{ print $1; }') \
29
  | awk '{ print "git branch -d -r origin/" $1; print "git checkout origin/" $1 " -b " $1; print ""; }'
30
echo