views:

40

answers:

1

I need to delete old and unmaintained branches from our remote repo. I'm trying to find a way with which to list the remote branches by their last modified date, and I can't.

Does someone know of an easy way to list remote branches this way?

+3  A: 

commandlinefu has 2 interesting propositions:

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

or:

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

That is for local branch, in a Unix syntax, but using git branch -r, you should be able to adapt that to only list what you need.

VonC
thanks! just what I needed!
Roni Yaniv
+1 for introducing me to commandlinefu!
hasen j
@hansen j: interesting, isn't it? It launched a few months after the public release of Stack Overflow (http://codeinthehole.com/archives/16-Current-pet-project-Command-Line-Fu.html), and was somewhat inspired by SO. See also http://www.commandlinefu.com/commands/tagged/67/git for more git commandlinefu ;)
VonC