Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kentlouisetonino/595652d525add39f993b0720feac00e0 to your computer and use it in GitHub Desktop.
Save kentlouisetonino/595652d525add39f993b0720feac00e0 to your computer and use it in GitHub Desktop.
Description

Go to the /usr/bin directory and create a file.

cd /usr/bin

sudo touch delete-git-branches-except && sudo vim delete-git-branches-except

Add the script and save.

#!/bin/bash

git branch | grep -v $1 | xargs git branch -D

Make it executable globally.

sudo chmod +x delete-git-branches-except

Execute in the command line.

delete-git-branches-except main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment