git 本地 branch 按照使用时间排序
使用 git 做开发, 我们的 branch 策略是每个新功能, 每个要修改的bug 都在一个单独的 branch 上坐开发. 久而久之, 本地就有很多 branch 了, 有些还没有合并到 master 分支上, 有些是正在开发的本地 branch.
如何查看最近使用的 branch?
# 查看最近使用的 branch 时间先后排序
git branch -l --sort committerdate
# 查看最近使用的 branch 时间倒序排序
git branch -l --sort -committerdate
# 查看最近使用的 branch 时间倒序排序
git for-each-ref --sort=-committerdate refs/heads/
# 查看最近使用的 branch 时间倒序排序 特定格式
git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:iso8601) %(refname:short)'