git log --since 排除第一次提交
git log --since is excluding the first commit
假设一个 git 存储库有 12 个提交,其中 4 个是 昨天 创建的(假设 2199 年 12 月 31 日)。
git log --oneline
将输出:
9675a65 fix: a bug in feature B
041e1b2 feat: add feature B
d0f58e3 refactor: apply DPs to feature A
e933840 feat: add feature A
a6a235d chore: update version
...
f982bfd chore: initial commit
预期行为
根据我的理解,如果我今天 运行 git log --since=1.day
(2200 年 1 月 1 日)我应该得到一个输出,包括昨天的最后 4 次提交(在示例中:从 feat:添加功能 A 到 fix:功能 B 中的错误)。
实际行为
但是,我只得到最后 3 次提交(从 重构:将 DP 应用到功能 A 到 修复:功能 B 中的错误). git log --since=1.day
不包括昨天在其输出中创建的第一个提交(壮举:添加功能 A)。
我是不是漏掉了什么?
计算机时间总是比看起来更复杂。
在这种情况下,您似乎只是在考虑从特定日期选择提交。然而,在 Git 中,--since
(或具有相同含义的 --after
)计算精确的秒:
--after=2020-07-18
表示“在现在的任何时间之后,但在那一天”,并且:
--after=1.day.ago
表示“自 正好 1 天前 24 小时后”或“从这一秒减去 86400 秒,并将其用作后值”。你可以,如,更精确:
--after=2020-07-18-00:00:00
强制Git使用指定日期的午夜。
请注意 --before
/--until
和 --after
/--since
始终使用 提交者时间戳 ,而不是 作者时间戳。另见 Specification for syntax of git dates and this blog entry at alexpeattie.com as linked from this answer. For more background, see Falsehoods programmers believe about time.
假设一个 git 存储库有 12 个提交,其中 4 个是 昨天 创建的(假设 2199 年 12 月 31 日)。
git log --oneline
将输出:
9675a65 fix: a bug in feature B
041e1b2 feat: add feature B
d0f58e3 refactor: apply DPs to feature A
e933840 feat: add feature A
a6a235d chore: update version
...
f982bfd chore: initial commit
预期行为
根据我的理解,如果我今天 运行 git log --since=1.day
(2200 年 1 月 1 日)我应该得到一个输出,包括昨天的最后 4 次提交(在示例中:从 feat:添加功能 A 到 fix:功能 B 中的错误)。
实际行为
但是,我只得到最后 3 次提交(从 重构:将 DP 应用到功能 A 到 修复:功能 B 中的错误). git log --since=1.day
不包括昨天在其输出中创建的第一个提交(壮举:添加功能 A)。
我是不是漏掉了什么?
计算机时间总是比看起来更复杂。
在这种情况下,您似乎只是在考虑从特定日期选择提交。然而,在 Git 中,--since
(或具有相同含义的 --after
)计算精确的秒:
--after=2020-07-18
表示“在现在的任何时间之后,但在那一天”,并且:
--after=1.day.ago
表示“自 正好 1 天前 24 小时后”或“从这一秒减去 86400 秒,并将其用作后值”。你可以,如
--after=2020-07-18-00:00:00
强制Git使用指定日期的午夜。
请注意 --before
/--until
和 --after
/--since
始终使用 提交者时间戳 ,而不是 作者时间戳。另见 Specification for syntax of git dates and this blog entry at alexpeattie.com as linked from this answer. For more background, see Falsehoods programmers believe about time.