Skip to content

Instantly share code, notes, and snippets.

@angie
Created July 3, 2020 07:12
Show Gist options
  • Save angie/94154e1a49e3a3bbacba16a6a1716c3c to your computer and use it in GitHub Desktop.
Save angie/94154e1a49e3a3bbacba16a6a1716c3c to your computer and use it in GitHub Desktop.
# remove old local branches last updated > 2 months ago
for k in $(git branch | sed /\*/d); do
if [ -n "$(git log -1 --before='2 months ago' -s $k)" ]; then
git branch -D $k
fi
done
# list branches merged to master
git branch --merged master | grep -v "\* master"
# delete branches merged to master
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment