Freigeben über


Getting ancient remote branches in git

My project has 300+ remote branches for a 100-ish person team. That can't possibly be right.  Here's some powershell to detect super old branches so I can go annoy their owners about deleting them:

git branch -r | ?{ $_ -notlike "*/HEAD *" } | %{ git log $_.Trim() -n 1 --format=format:"%ct %d %h %an %ar" } | Sort-Object

The format is like:

1396576284  (origin/release) b3a96ad <name> 1 year, 1 month ago
1402418261  (origin/<alias>/Keyboard2) 83374b7 <name> 11 months ago
1402938550  (origin/<alias>/nopackages) 630cca0 <name> 11 months ago
1403027117  (origin/<alias>/SomeLongCompletedIntegration) ab7a735 <name> 11 months ago

Et voila, now I can find & zap branches with "git push origin --delete branchname"