How to to get past 30 days active branches from git?

Viewed 78

Is there any git command available which shows active branches past 30 days in github ?? For eg : git branch -r --no-merged this command show complete active branch but i want to see only those branches which is active from 30 days

2 Answers

There are times when plain git is just not the right tool for the job and some bash-fu is needed.

limit=$( date -v-30d +%s )
git branch -r --no-merged | while read branch; do
    if [ $( git show --quiet --pretty="%ct" $branch ) -lt $limit ]; then
        branch $branch has been inactive for longer than 30 days
    fi
done

git branch -r --no-merged [shows] complete active branch but i want to see only those branches which is active from 30 days

branches=`git branch -r --no-merged | awk '{print $1}'`
[[ -n $branches ]] && git log --no-walk --pretty=%D --since=30.days.ago $branches

or

branches=`git for-each-ref refs/remotes --format='%(refname)' --no-merged`
[[ -n $branches ]] && git log --no-walk --pretty=%D --since=30.days.ago $branches
Related