当我打字 git branch
,我收到一个分支列表,这些分支似乎按字母顺序排序,而不是按创建时间排序。
有没有办法让输出 git branch
按日期排序?
当我打字 git branch
,我收到一个分支列表,这些分支似乎按字母顺序排序,而不是按创建时间排序。
有没有办法让输出 git branch
按日期排序?
编辑
唉,采取的排序选项存在明显的问题 git-for-each-ref
。由于该命令(显然)明确地旨在显示 refs
和 接受 --sort
选项,我认为这可能是一个错误[1]。
这是我可以进一步提出的最佳选择,但输出与原始格式相差甚远(因为它们依赖于事后的装饰修订来引用分支)。好吧,也许它对你有用:
[1]如果是这样的话 git-rev-list
要么 git-log
我认为问题在于我们实际上并非如此 步行 修订树;我们正在积极尝试只展示 提示 树木,没有走路。
git log --no-walk --date-order --oneline --decorate \
$(git rev-list --branches --no-walk)
这会给你一个类似的列表
4934e92 (HEAD, origin/testing, origin/HEAD, testing) reviewed INSTALL file as per #1331
6215be7 (origin/maint, maint) reviewed INSTALL file as per #1331
1e5e121 (origin/emmanuel, emmanuel) buffers: adjust the size in zfsfuse_stat
e96783e (origin/compress, compress) buffers: adjust the size in zfsfuse_stat
f6e2c6c (origin/unstable, unstable) revert the fatal condition again
dd52720 (origin/master-lucid, master-lucid) lucid
3b32fa7 (tag: 0.7.0, origin/master, master) panic revocation of 0.7.0-0 package necessitates an update
6eaa64f (origin/maint-0.6.9, maint-0.6.9) Replace remount by drop_caches (on rollback)
_正如您所看到的,在存在许多远程(跟踪)分支的情况下,结果可能会有点压倒性,这些分支实际上是对相同修订的别名。但是,结果按(降序)日期正确排序。
不,但你应该可以做到
git for-each-ref --sort='-*committerdate' --format="%(refname:short)" refs/heads/
(使用 --sort='-*authordate'
作者日期订购)
在我的测试回购中,这会产生:
compress
emmanuel
maint
maint-0.6.9
master
master-lucid
testing
unstable
你可以创建一个git别名来执行此操作:将以下行追加到 .git/config
[alias]
branch2 = git for-each-ref --sort='-*committerdate' --format="%(refname:short)" refs/heads/
从那以后,你可以说 git branch2