I work with some rather messy developers, and our larger repos have close to 100 branches, most of which are abandoned. They usually don't cause issues but once in a while they get in the way. I work in my own fork, so I could locally set one-branch tracking for origin
, but I'm afraid that could bite me in the butt eventually.
An in-between solution would be to only fetch branches with recent activity, e.g. newest commit is within the last 90 days or something. Is there any way to do that? (Git refspec doesn't seem to mention this, so maybe not.)
One thing I've poked around with was to git branch -rd
old branches after fetching, but when it comes to scripting that gets complicated quickly (e.g. by adapting this to remote-tracking branches: Delete all branches that are more than X days/weeks old).