DEV Community

Discussion on: Git basics: remove all local branches

Collapse
 
damian_cyrus profile image
Damian Cyrus

Very handy one-liners.

There should be a git command especially for this cases. Something like:

git branch --all-branches --merged --delete --ignore="fix-this-bug,prefix-*"
Enter fullscreen mode Exit fullscreen mode

And the main branch is ignored by default, to not do something dangerous. Maybe also a hint if you delete a branch when you are checkout into it at the moment ...

Or some similar feature, with a good described documentation in one place πŸ˜„

Collapse
 
dailydevtips1 profile image
Chris Bongers

There should really be a really good cleanup way actually.
Heck, even simply an automated way, merged branch -> get info back to delete it when it's not active anymore.

But at the very least indeed a option to make it easier and safe for people to do this.

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

Git is a goldmine for content creators.

So many common tasks don't have an intuitive solution, and the official documentation has a chicken and egg problem where you can search only what you already know how to do.

So lots of Google traffic.