2012-02-10 33 views
19

如何列出按最後提交日期顯示和排序的git分支?Git:列出git分支,排序(並顯示)日期

我發現this

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 -r 

我期望平原GIT中有此功能。可以?我也發現git show-branch --date-order但輸出是不同的。

+0

如果年齡大了,這怎麼可能是重複的? – 2017-11-14 16:16:21

+0

如何在2012年提出這個問題並在2011年提出另一問題? – 2017-11-14 19:49:43

+0

好吧,我的壞。我在看2014年的編輯。 Thx&appology – 2017-11-15 21:44:25

回答

42

這似乎是一個內置的方式來實現這一(v1.7.4):

git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)' 
+2

在1.4.4中增加了'git for-each-ref'。 – jthill 2013-06-06 15:06:33

+0

沒有類似的遠程分支,但我可以找到 – 2014-08-31 00:48:45

+3

@ Ry4an使用'refs/remotes /'而不是'refs/heads /' – SQB 2016-05-13 10:29:02

-2

不,它沒有內置此功能。

3

我很喜歡的@Will謝潑德解決方案,把一些顏色。

git for-each-ref --sort=committerdate refs/heads/ --format='%(color: red)%(committerdate:short) %(color: cyan)%(refname:short)'