Last active
October 23, 2017 15:59
-
-
Save christianb/623a983f2b258700a1f8f6160351d923 to your computer and use it in GitHub Desktop.
Shows list of branches and their age.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Shows all remote branches and their age. | |
# | |
# Passing -n <name_of_commiter> shows only the branches last touched by that person. | |
# Passing -b <branch> shows only branches of that type (release, feature, experimental, etc) | |
# Passing -t <time> (day, week, month, year) | |
# | |
# Arguments can be combined. | |
git remote update origin --prune | |
showBranch() { | |
for k in `git branch --list ${branch} -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do | |
echo -e `git show --pretty=format:"%ci %Cblue%cr %Cred%aE %Creset" $k -- | head -n 1`\\t$k; | |
done | sort -r | grep -e "$name" | grep "$time" | |
} | |
branch="origin/*" | |
while getopts n:b:t: option | |
do | |
case "${option}" in | |
n) name=${OPTARG};; | |
b) branch="origin/"${OPTARG}"*";; | |
t) time=${OPTARG};; | |
esac | |
done | |
showBranch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment