- 主题: git log format:<format-string> 用法请教
大家好!
想调整下 git log 的输出格式,man git-log, 有看到 pretty 有如下说明:
format:<format-string> 章节下面:
%(describe[:options])
human-readable name, like git-describe(1); empty string for undescribable
commits. The describe string may be followed by a colon and zero or more
comma-separated options. Descriptions can be inconsistent when tags are added
or removed at the same time.
? tags[=<bool-value>]: Instead of only considering annotated tags, consider
lightweight tags as well.
请问有哪位知道如何把 当前提交最新 的 tags 版本号显示出来吗?
--
FROM 111.55.137.*
哎, 在 Debian 打包中的 debian/watch 文件,只认
git log 命令里面的 tformat 格式化字符串扩展。
我目前找到的信息就是 , git-log 的这个 格式化字符串里面,就没有 tag 的信息。
【 在 oicu 的大作中提到: 】
: 看你要什么效果了
: git log --oneline --tags -1
: git show-ref --tags
: ...................
--
FROM 39.144.15.*
%d %D 确实可以显示出 tag 信息。
其实我想实现的是,一个软件包的版本号,使用
git describe --tags 的输出再加上日期。
如 1.0.3-2-g584bb9c,修改为 1.0.3-2-20230515-g584bb9c
这个能否使用 git log 的 --pretty=format: 实现吗?
【 在 oicu 的大作中提到: 】
: 这个是我自用的,在 --oneline 模式上增加显示修改时间、作者:
: git log --graph --pretty=format:"%C(yellow)%h%C(auto)%d%C(reset) %s %C(green)(%cd) %C(bold blue)<%an>" --date=format:"%Y-%m-%d %T"
: %d就是显示分支、tag等名称信息的啊
: ...................
--
FROM 39.144.13.*
是的,谢谢!
最后我用了:
git log --pretty=tformat:"%(describe:tags)-%cs" --date=format:"%Y%m%d" -1
如:
1.0.2-124-g92e2962-2023-04-21
这样就发布比较 deb 软件包的版本号了,使用前面的 1.0.2-124 就可以比较大小了。
【 在 oicu 的大作中提到: 】
: 我猜测你想要的效果是:
: git log --pretty=format:"%(describe:tags)-%cd-%h" --date=format:"%Y%m%d" --abbrev-commit --tags --no-walk -1
: 不写 -1 就是列出所有的 tag,看附件的图示。
: ...................
--
FROM 111.55.141.*
%cs
committer date, short format (YYYY-MM-DD)
是的,%cs 直接默认使用 YYYY-MM-DD 格式。
【 在 oicu 的大作中提到: 】
: %cs 不需要--date=format
--
FROM 39.144.12.*