Skip to content

Instantly share code, notes, and snippets.

@kylemacey
Last active August 24, 2021 15:42
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kylemacey/8978205 to your computer and use it in GitHub Desktop.
Save kylemacey/8978205 to your computer and use it in GitHub Desktop.
This gist will create a custom git script that will delete any branches that are fully merged into the currently checked out branch (usually run on master)
mkdir -p ~/scripts/git
echo 'git branch --merged | grep -wiv -e "main" -e "master" | xargs -n 1 git branch -d' > ~/scripts/git/git-bomb
echo 'git remote prune origin' >> ~/scripts/git/git-bomb
chmod +x ~/scripts/git/git-bomb
sudo ln -s ~/scripts/git/git-bomb /usr/bin/git-bomb
@vormwald
Copy link

don't delete master -> 'git branch --merged | grep -v "\*\|master" | xargs -n 1 git branch -d'

@kylemacey
Copy link
Author

@vormwald thanks! done.

@iamkirkbater
Copy link

It's been 7 years now and I still love this script. <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment