的输出git tag
按字母顺序排列。我希望它按时间顺序排列(它们被分配到的提交的日期,而不是它们的创建日期),否则输出应该保持不变。
我已经尝试了http://networkadmin20.blogspot.de/2010/08/howto-list-git-tags-by-date.html的建议,但顺序仍然相同。
为了确保我的存储库没有错误,我使用干净的存储库尝试了以下操作:
soeren@ubuntu ~/Projects/sandbox % mkdir chronogit
soeren@ubuntu ~/Projects/sandbox % cd chronogit
soeren@ubuntu ~/Projects/sandbox/chronogit % git init
Initialized empty Git repository in /home/soeren/Projects/sandbox/chronogit/.git/
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % touch a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git add a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'a'
[master (root-commit) f88e0e9] a
0 files changed
create mode 100644 a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'A-first'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git mv a b
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'c'
[master ecc0c08] c
1 file changed, 0 insertions(+), 0 deletions(-)
rename a => b (100%)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'C-second'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git mv b c
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'b'
[master e72682d] b
1 file changed, 0 insertions(+), 0 deletions(-)
rename b => c (100%)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'B-third'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag
A-first
B-third
C-second
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git for-each-ref refs/tags --sort=taggerdate --format="%(refname:short)"
A-first
B-third
C-second
所需的输出是:
A-first
C-second
B-third
或者,因为反转它不应该太难:
B-third
C-second
A-first
编辑:正如评论中指出的,这个问题非常相似,所以我尝试了以下方法:
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --pretty="format:%ai %d"
2013-09-06 16:08:43 +0200 (HEAD, B-third, master)
2013-09-06 16:08:21 +0200 (C-second)
2013-09-06 16:07:42 +0200 (A-first)
顺序很好,但现在我正在与格式作斗争......</p>
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --pretty="format:%(refname:short)"
%(refname:short)
%(refname:short)
%(refname:short)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --format="%(refname:short)"
%(refname:short)
%(refname:short)
%(refname:short)