Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.commandlinefu.com/commands/view/2345/show-git-branches-by-date-useful-for-showing-active-branches" rel="noreferrer">commandlinefu</a> has 2 interesting propositions:</p> <pre><code>for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r </code></pre> <p>or:</p> <pre><code>for k in `git branch | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k --`\\t"$k";done | sort </code></pre> <p>That is for local branches, in a Unix syntax. Using <code>git branch -r</code>, you can similarly show remote branches:</p> <pre><code>for k in `git branch -r | perl -pe 's/^..(.*?)( -&gt;.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r </code></pre> <hr> <p><a href="https://stackoverflow.com/users/191991/michael-forrest">Michael Forrest</a> mentions <a href="https://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git/2514279#comment27884192_2514279">in the comments</a> that zsh requires escapes for the <code>sed</code> expression:</p> <pre><code>for k in git branch | perl -pe s\/\^\.\.\/\/; do echo -e git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1\\t$k; done | sort -r </code></pre> <p><a href="https://stackoverflow.com/users/1025068/kontinuity">kontinuity</a> adds <a href="https://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git/2514279#comment65532526_2514279">in the comments</a>:</p> <blockquote> <p>If you want to add it your zshrc the following escape is needed. </p> </blockquote> <pre><code>alias gbage='for k in `git branch -r | perl -pe '\''s/^..(.*?)( -&gt;.*)?$/\1/'\''`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r' </code></pre> <p>In multiple lines:</p> <pre><code>alias gbage='for k in `git branch -r | \ perl -pe '\''s/^..(.*?)( -&gt;.*)?$/\1/'\''`; \ do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | \ head -n 1`\\t$k; done | sort -r' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload