我正在寻找一种方法来按照@ { - 1},@ { - 2},@ { - 3}等参考的顺序列出git分支。 git branch --sort
允许“authordate”和“committerdate”,但找不到像“visitdate”这样的内容。
答案 0 :(得分:4)
我不知道如何找到“上次访问的日期”。然而,有一种方法可以按照他们被访问的(反向)时间顺序列出分支:
git
通过检查reflog找到@ { - 1},@ { - 2},@ { - 3}等,并保持线条像checkout: moving from aaa to bbb
一样。
你可以从同样的行为中找到出路:
git reflog | grep -o "checkout: moving from .* to " |\
sed -e 's/checkout: moving from //' -e 's/ to $//' | head -20
评论:
# inspect reflog :
git reflog |\
# keep messages matching 'checkout: ...'
# using -o to keep only this specific portion of the message
grep -o "checkout: moving from .* to " |\
# remove parts which are not a branch (or commit, or anything) name :
sed -e 's/checkout: moving from //' -e 's/ to $//' |\
# keep only last 20 entries
head -20