3 ms·
> 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 followin
by war1025 7y ago
> 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.
- bjg 7y agogit-gone does this as well, works cross platform. https://github.com/lunaryorn/git-gone https://github.com/lunaryorn/git-gone
- matanrubin 7y agoDo you need to compile and install it from source? I couldn't find it on homebrew
- Buttons840 7y agoMy approach: refage = ! git for-each-ref --format='%(committerdate:relative),%(authorname),%(refname)' --sort -committerdate | column -t -s ',' This will list all refs (including tags, so you might want to grep the output), their relative ages, and who the last commit author was, and then formats it nicely. This makes it easy to see how many branches there and how old they are, as well as who to contact to request deletion.
- Buttons840 7y agoThe above line is a git alias. I failed to mentioned that.