Skip to content

Instantly share code, notes, and snippets.

@kanapuli
Forked from mroderick/find-old-branches.sh
Created July 12, 2019 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanapuli/b25a9b4ac53bad9c3b430adcd0231f46 to your computer and use it in GitHub Desktop.
Save kanapuli/b25a9b4ac53bad9c3b430adcd0231f46 to your computer and use it in GitHub Desktop.
A small script to find stale branches
#!/bin/bash
# This is a very naive script, it doesn't do grouping and returns all branches
# I only really care about branches that have not seen commits in two months
#
# I am hoping to find some time to write a tool that can output these reports for me
# In the meantime, I am using this
echo "Merged branches"
for branch in `git branch -r --merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r
echo ""
echo "Not merged branches"
for branch in `git branch -r --no-merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment