Skip to content

Instantly share code, notes, and snippets.

@bmiselis
Created August 6, 2019 20:00
Show Gist options
  • Save bmiselis/9cbc92679449efe91de1943f841b470f to your computer and use it in GitHub Desktop.
Save bmiselis/9cbc92679449efe91de1943f841b470f to your computer and use it in GitHub Desktop.
Clean repository after Pull Request has been successfully merged.
#!/bin/bash
# Go to user-specified branch.
git checkout $1
# Get newest changes after PR merge.
git pull
# Update tracked remote branches.
git fetch --prune
# Delete all local branches that are already merged to master.
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment