Listing remote branches with commit author and age of last commit

Here’s a simple bash script that shows how to enumerate remote Git branches:

for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%ci\t%cr\t%an" $k -- | head -n 1`\\t$k; done | sort -r

The resulting output looks like this:

2019-09-26 20:42:44 +0200 8 weeks ago Emil Åström origin/master
2019-09-26 20:42:44 +0200 8 weeks ago Emil Åström origin/HEAD
2019-05-17 23:06:41 +0200 6 months ago Emil Åström origin/fix/travis-test-errors
2018-04-21 23:16:57 +0200 1 year, 7 months ago Emil Åström origin/fix/nlog-levels

For a selection of other fields to include, see the git-show documentation.

(Adapted from https://stackoverflow.com/a/2514279/736684).

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.