Skip to content

Instantly share code, notes, and snippets.

@danie1k
Created January 20, 2018 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danie1k/e10ff590b4602b12c84320ff24501154 to your computer and use it in GitHub Desktop.
Save danie1k/e10ff590b4602b12c84320ff24501154 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
tarBranch=$(git branch -r --merged | grep -v master | grep -v develop | sed 's/origin\///')
for branch in $tarBranch
do
echo "Branch: $branch"
lastDate=$(git show -s --format=%ci origin/$branch)
convertDate=$(echo $lastDate | cut -d' ' -f 1)
Todate=$(date -d "$convertDate" +'%s')
current=$(date +'%s')
day=$(( ( $current - $Todate )/60/60/24 ))
echo " last commit on $branch branch was $day days ago"
if [ "$day" -gt 90 ]; then
echo " delete the old branch $branch"
git push origin :$branch
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment