5 ms·
I like throw an alias and date stamp in their too: <alias>/<yyyyMMdd>_some_short_description <alias>/<yyyyMMdd>_<task-id>_some_short_description as it
by rhplus 6y ago
I like throw an alias and date stamp in their too:
<alias>/<yyyyMMdd>_some_short_description
<alias>/<yyyyMMdd>_<task-id>_some_short_description
as it makes cleaning up old branches (both local and remote) just a little bit easier. Author left the team? Delete. Untouched from 6 months back? Delete.
- Naac 6y agoI am a fan of the alias as well. I'm not a huge fan of the timestamp as it makes viewing a list of branches a little noisy. I think instead you can use this[0] solution to delete branches older than X days. [0] https://stackoverflow.com/a/10325758 https://stackoverflow.com/a/10325758
- marcandre 6y agoI find it simpler to always list my branches sorted by last commit date (with `git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'`). You can probably modify it to show the last author / date too.
- war1025 6y 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 6y agogit-gone does this as well, works cross platform. https://github.com/lunaryorn/git-gone https://github.com/lunaryorn/git-gone
- matanrubin 6y agoDo you need to compile and install it from source? I couldn't find it on homebrew
- Buttons840 6y 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 6y agoThe above line is a git alias. I failed to mentioned that.
- FalconSensei 6y ago> cleaning up old branches For remote, you should just delete when you merge OR, when doing the cleanup, delete the old and merged branches. For local, just remove branches that are not on remote anymore