Skip to content

Instantly share code, notes, and snippets.

@CJHwong
Created February 6, 2025 15:52
Show Gist options
  • Save CJHwong/876b63f7dc4aa21de924bc28a0268306 to your computer and use it in GitHub Desktop.
Save CJHwong/876b63f7dc4aa21de924bc28a0268306 to your computer and use it in GitHub Desktop.
Git: Find Old Remote Branches
git fetch --all --prune && git for-each-ref --format=$'%(committerdate:unix)\t%(refname:lstrip=2)\t%(committername)' refs/remotes/ | awk -F'\t' -v cutoff=$(date -v-3m +%s) '
$1 < cutoff {
committer = $3;
branches[committer] = branches[committer] "\n - " $2;
}
END {
for (c in branches) {
print c ":" branches[c];
print "==========================";
}
}' > old_remote_branches_report.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment