Show git branches by date - useful for showing active branches

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
Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.
Sample Output
2009-06-03 12:21:35 +0900 3 hours ago	add_cool_functionality
2009-06-02 16:15:13 +0900 24 hours ago	remove_strange_bug
2009-06-02 16:12:20 +0900 24 hours ago	implement_observer
2009-06-02 14:42:58 +0900 25 hours ago	experiment_with_bobcat_feature

16
By: brunost
2009-06-03 08:25:00

8 Alternatives + Submit Alt

What Others Think

Is there a good way to add that to the git alias?
youthenme · 567 weeks and 1 day ago
You can't add it as a git alias because it's using a bash for loop to run the command several times. What you can do is add a script at /usr/local/bin/git-branch-dates containing: #!/bin/bash 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 Git automatically searches through any bash scripts on your path that start with git- so you can now run: git branch-dates and the script will be run.
unixmonkey36469 · 455 weeks and 5 days ago
Of course you can add it as a git alias! A git alias which is "!f() { ...bash script here...; }; f" works just fine. So, if you add an alias which says brel = "!f() { 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; }; f" git brel will do the proper thing. Of course, the single command git for-each-ref --sort=-committerdate --format='%1B[32m%(committerdate:iso8601) %1B[34m%(committerdate:relative) %1B[0;m%(refname:short)' refs/heads/ is easier to alias :)
mstormo · 416 weeks and 5 days ago
You’ve got some interesting points in this article. I would have never considered any of these if I didn’t come across this. Thanks!. click" rel="nofollow">http://libjournal.uncg.edu/ap/user/viewPublicProfile/5446'>click this site
bojokey283 · 9 weeks and 6 days ago
i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future.. look at this http://personeriadebarranquilla.gov.co/?option=com_k2&view=itemlist&task=user&id=3107
bojokey283 · 9 weeks and 5 days ago
I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!. read more http://libjournal.uncg.edu/ap/user/viewPublicProfile/5446
xoheko1229 · 9 weeks and 3 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. forex
bojokey283 · 8 weeks and 3 days ago
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. blinds installation
bojokey283 · 8 weeks and 3 days ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. coronavirus playa del carmen
bojokey283 · 8 weeks and 2 days ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. covid isla mujeres
bojokey283 · 8 weeks and 2 days ago
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. online marketing
bojokey283 · 7 weeks and 3 days ago
Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. house clearance bridgend
bojokey283 · 7 weeks and 3 days ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. upholstery cleaning
bojokey283 · 7 weeks and 3 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. taco catering
bojokey283 · 7 weeks and 2 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. buy targeted traffic
bojokey283 · 6 weeks and 6 days ago
I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!.. Turmeric Essential Oil
bojokey283 · 6 weeks and 5 days ago
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers. tulum mexico weather
bojokey283 · 4 weeks and 5 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. schluesseldienst köln
bojokey283 · 4 weeks and 3 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. cancun
bojokey283 · 3 weeks ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing tulum
bojokey283 · 3 weeks ago
I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. korrekt ügyvéd Debrecen
bojokey283 · 2 weeks and 2 days ago
Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. cenote manati
xoheko1229 · 1 week and 5 days ago
Thank you for this. It will be really helpful. white goods removal gold coast
FLM76 · 1 week and 4 days ago
Really a great addition. I have read this marvelous post. Thanks for sharing information about it. I really like that. Thanks so lot for your convene. otomatisasi rumah https://www.tiscontrol.com/tptis/id/index.html
bojokey283 · 1 week and 3 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. otomatisasi rumah
bojokey283 · 1 week ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. jelent?s pályázatírás Debrecen
bojokey283 · 4 days ago
I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. best beach in cozumel
xoheko1229 · 3 days ago
Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. reefs in cozumel
xoheko1229 · 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: