Closed john-science closed 5 years ago
Here's my first stab at the script:
#!/bin/bash
#############################################################
# Find the loneliest branches in your Git repo. #
# #
# i.e. Sort all the branches in a local Git repo by the #
# date of their last commit, and show the commiter. #
# #
# WARNING: This script will be slow for large repos. #
#############################################################
# set file paths
OUT='lonely_branches.txt'
# bring your local repo up to date
git fetch --all
# prune all the origin-deleted branches locally
git fetch --prune
# find all branches and sort them by age and commiter
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%cd, %an," --date=format:'%Y-%m-%d' $branch | head -n 1` \\t$branch; done | sort -r | sed 's/origin\///g' | sed 's/\t//g' | sort -u > ${OUT}
Branch Cleaning
May I recommend a little Spring Cleaning?