Git: 如何找到一个commit何时合并到master?

Git: How to find when a commit was merged into master?

我想在我的项目中创建一个指标来衡量提交从创建到进入主分支需要多长时间。

可能吗?对于快进提交,我似乎无法从 git 日志中获取此信息。

如果我能得到 X 天前存储库的快照,也许我可以计算它。另一种选择是获取在修改分支 HEAD 时注册的日志。

更新: 如果您在每次发布时创建带注释的标签,您只能看到包含提交的标签的日期。这是list the commits included in a tag

的方法

这并不容易,考虑到提交本身并不知道它在哪个分支。
它不跟踪分支 "events",它会提到它是在分支 X 中创建的,然后在分支 Y 中合并(可能快进)。

git reflog registers HEAD changes, but it is limited in time.

如 OP 所述,您需要添加 元数据(如 annotated tag, but you could also consider a git notes)以记住您需要的信息。