Skip to content

Instantly share code, notes, and snippets.

View stephendougherty's full-sized avatar

Stephen Dougherty stephendougherty

View GitHub Profile
@motemen
motemen / git-remove-old-branches
Created December 29, 2011 07:48
remove old remote git branches interactively
#!/bin/sh
git fetch
for branch in `git branch --remote --merged origin/master | sed 's/ *origin\///' | grep -v ' ' | grep -v 'master$'`
do
MERGE_EPOCH=$(git --no-pager log -1 --pretty='%ct' $(git merge-base origin/master origin/$branch))
CURRENT_EPOCH=$(git --no-pager log -1 --pretty='%ct' origin/master)
if [ $(expr $(expr $CURRENT_EPOCH - $MERGE_EPOCH) / 60 / 60 / 24) -ge 14 ]; then