Skip to content

Instantly share code, notes, and snippets.

@msepcot
Last active June 27, 2016 21:03
Show Gist options
  • Save msepcot/5579255 to your computer and use it in GitHub Desktop.
Save msepcot/5579255 to your computer and use it in GitHub Desktop.
Bash script to output a list of git branches sorted by last commit date, include last commit author's name.
#!/bin/bash
$(git fetch --prune)
for branch in $(git branch -r); do
if ([ "$branch" == "origin/HEAD" ] || [ "$branch" == "origin/master" ] || [ "$branch" == "origin/develop" ] || [ "$branch" == "->" ] || [[ "$branch" =~ origin\/[0-9]+\.[0-9](\.[0-9])?$ ]]); then
continue
fi
printf "$(git log $branch -n1 --pretty=format:"%an (%ad): $branch" --date=short)\n";
done | sort
@msepcot
Copy link
Author

msepcot commented May 1, 2015

added filter to remove release branches in the form: origin/X.Y(.Z)

@msepcot
Copy link
Author

msepcot commented Jun 27, 2016

added filter to remove 'develop' branch and origin/XX.Y(.Z) release branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment