Sandip Mane
by Sandip Mane
~1 min read

Categories

  • Git

Tags

  • git

After working on a project for a while, we normally end up having too many branches locally.

I cleanup all github branches from my local using the following command. Thought to share it for all those OCD’ians out there!

Delete merged branches except default

If you’re someone who do not want to lose unmerged branches, use this command.

git branch --merged | grep -v \* | xargs git branch -D

Delete all the branches except default

Personally, I push all the branches to git as soon as I create them, so it’s not a dealbreaker for me to delete them from local.

git branch | grep -v \* | xargs git branch -D