Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Forked from jasonrudolph/git-branches-by-commit-date.sh
Last active August 29, 2015 14:11
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 nickleefly/f59524689c99fd69cc8e to your computer and use it in GitHub Desktop.
Save nickleefly/f59524689c99fd69cc8e to your computer and use it in GitHub Desktop.
git branch by date
git branch -vv --color=always | while read; do echo -e $(git log -1 --format=%ci $(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') 2> /dev/null || git log -1 --format=%ci)" $REPLY"; done | sort -r | cut -d ' ' -f -1,4-

git for-each-ref --format='%(committerdate:iso8601) %(committerdate:relative) %(refname)' --sort -committerdate
git for-each-ref --format='%(committerdate:iso8601) %(committerdate:relative) %(refname)' --sort -committerdate refs/heads/
git for-each-ref --format='%(committerdate:short),%(authorname),%(refname:short)' --sort=committerdate refs/heads/ | column -t -s ','

for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
for branch in `git branch -l | grep -v '*'`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r

for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r

for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cred%cr%Creset" $k | head -n 1`\\t$k; done | sort -r
for k in `git branch | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cred%cr%Creset" $k --`\\t"$k";done | sort

for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cred%cr%Creset" $k | head -n 1`\\t$k; done | sort -r
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
# Example output (resulting from running command on the Rails repo — https://github.com/rails/rails)
2012-02-12 03:20:24 -0800 9 hours ago origin/master
2012-02-10 10:34:35 -0800 2 days ago origin/3-2-stable
2012-01-31 09:56:12 -0800 12 days ago origin/3-1-stable
2012-01-24 11:18:06 -0800 3 weeks ago origin/3-0-stable
2011-12-31 05:09:14 -0800 6 weeks ago origin/2-3-stable
2011-11-25 09:49:54 +0000 3 months ago origin/serializers
2011-06-16 12:08:26 -0700 8 months ago origin/compressor
2011-05-24 16:03:41 -0700 9 months ago origin/sass-cleanup
2011-01-17 14:14:24 +1300 1 year, 1 month ago origin/2-1-stable
2011-01-17 14:13:56 +1300 1 year, 1 month ago origin/2-2-stable
2010-08-17 17:11:17 -0700 1 year, 6 months ago origin/deps_refactor
2010-05-16 22:23:44 +0200 1 year, 9 months ago origin/encoding
2009-09-10 17:41:18 -0700 2 years, 5 months ago origin/2-0-stable
2008-02-19 02:09:55 +0000 4 years ago origin/1-2-stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment