Git:列出 git 分支,按(并显示)日期排序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9236219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: List git branches, sort by (and show) date
提问by Ondra ?i?ka
How can I list git branches showing and sorting by their last commits' dates?
如何列出按上次提交日期显示和排序的 git 分支?
I've found 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
I'd expect plain git to have this feature. Does it?
我希望普通的 git 有这个功能。可以?
I also found git show-branch --date-order
but the output is something different.
我也发现git show-branch --date-order
但输出是不同的。
回答by Will Sheppard
This appears to be a built-in way to achieve that (v1.7.4):
这似乎是实现该目标的内置方法 (v1.7.4):
git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
回答by JmLavoier
I've enjoyed the @Will Sheppard solution to put some colors.
我很喜欢@Will Sheppard 解决方案来添加一些颜色。
git for-each-ref --sort=committerdate refs/heads/ --format='%(color: red)%(committerdate:short) %(color: cyan)%(refname:short)'