Repository navigation
Expand file tree
/
Copy pathgrc
More file actions
executable file
·39 lines (35 loc) · 1.31 KB
/
Copy pathgrc
File metadata and controls
executable file
·39 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
if [ "$#" -ne 2 ]; then
fileName="${0##*/}"
echo "Illegal number of parameters $#"
echo "Recieved args:"
echo " $@"
echo "Usage ${fileName} \${remote to check for merged changes} \${remote to clean}"
echo ""
echo "${fileName} origin/master hibooboo2"
echo ""
echo "Would delete all branches on hibooboo2 that have been merged to origin/master"
echo "Also would delete all local merged branches."
exit 1
fi
num="$[$(git branch --all --merged ${1} | grep remotes/${2} | wc -l) + $(git branch --all --merged ${1} | grep -v remotes| wc -l)]"
[[ $(echo ${num}) == 0 ]] && echo No Branches need cleaning. && exit 0
git branch --all --merged ${1} | grep remotes/${2} | grep -v remotes/${2}/master | grep -v remotes/${2}/develop | grep -v remotes/${2}/HEAD
git branch --all --merged ${1} | grep -v remotes | grep -v \*
echo Delete all of these branches? \(Y/N\)
read answer
if [ "${answer}" == "Y" ]
then
remoteBranches="$(git branch --all --merged ${1} | grep remotes/${2} | cut -d / -f 3)"
localBranches=$(git branch --all --merged ${1} | grep -v remotes | grep -v \*)
for i in ${remoteBranches}
do
git push --no-verify --delete ${2} ${i} &
done
for i in ${localBranches}
do
git branch -d ${i}
done
else
echo No branches deleted.
fi