Comment

Comment by war1025

> it makes cleaning up old branches (both local and remote) just a little bit easier

Slightly different from what you are referring to, but I have the following aliases that are super useful for cleaning up dead branches locally. They make running `git branch` actually return a reasonable list of branches rather than every branch I ever checked out in the past eight years.

   listdead = "!sh -c \"git branch -vv | grep ': gone]' | awk '{print \\$1}'\""
   prunedead = "!sh -c \"git branch -vv | grep ': gone]' | awk '{print \\$1}' | xargs git branch -D\""

So I will run `git listdead` after I merge something and pull the latest `master`. Then it will usually show the branches that I have merged recently.

Then I run `git prunedead` and it goes through and actually deletes them.

I've never run into a case where branches I didn't want removed were in the dead list, but I usually run `listdead` first just in case.

I think I swiped these from a StackOverflow answer at some point. Don't remember.

parent war1025 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton