Logo

dev-resources.site

for different kinds of informations.

Clean your git branches local and remote

Published at
11/18/2020
Categories
git
bash
Author
Luigui Moreno
Categories
2 categories in total
git
open
bash
open
Clean your git branches local and remote

Often after a few months of work I find myself with way too many git branches in my local repos, looking for in the internet how to delete local and remote branches in git, well, I have created a bash function for that, and now I'm goint to share it:

Add this to your bash profile

gitrm () { git branch -d $1 && git push origin :$1  }
gitrmf () { git branch -D $1 && git push origin :$1  }

Usage:

gitrm fix/fix-this-breaks-that

To force delete local not merged branches

gitrmf feature/we-dont-even-need-his-feature-anymore

Featured ones: