如何在使用 git commit --edit-message 时编辑提交日期?
How to edit the commit date when using git commit --reedit-message?
我最近使用 git commit --reedit-message=HEAD
,在使用 HEAD 中的大部分文本的同时进行新的提交。一切顺利,直到我观察到在提交后,新提交显示与之前的 HEAD 相同的日期戳。
日志(漂亮)是这样的
hash , auth date , message
86fb360, 2019-11-16, copied commit (committed on 2019-11-21)
6dc9583, 2019-11-16, original commit (committed on 2019-11-16)
基本日志命令git log -1
也显示旧日期。
为什么会这样?
如何在使用上述命令时使实际提交日期出现在新提交上?
这是意料之中的事情。
来自文档中的 -C <commit>
section :
Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
(强调我的)
然后 -c
/ --reedit-message
用 "Like -C, but ..."
引用它
根据您的确切需要,您可能做的是 --amend
最后一次提交并设置任何 date/author 或您想要的其他元数据。如果你不改变任何东西,请注意,提交者日期仍然是你进行修改的那一刻,而不是原始日期,希望这是你试图获得的?
git commit -c @ --reset-author
--reset-author
更新作者信息,包括时间戳。
我最近使用 git commit --reedit-message=HEAD
,在使用 HEAD 中的大部分文本的同时进行新的提交。一切顺利,直到我观察到在提交后,新提交显示与之前的 HEAD 相同的日期戳。
日志(漂亮)是这样的
hash , auth date , message
86fb360, 2019-11-16, copied commit (committed on 2019-11-21)
6dc9583, 2019-11-16, original commit (committed on 2019-11-16)
基本日志命令git log -1
也显示旧日期。
为什么会这样?
如何在使用上述命令时使实际提交日期出现在新提交上?
这是意料之中的事情。
来自文档中的 -C <commit>
section :
Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
(强调我的)
然后 -c
/ --reedit-message
用 "Like -C, but ..."
根据您的确切需要,您可能做的是 --amend
最后一次提交并设置任何 date/author 或您想要的其他元数据。如果你不改变任何东西,请注意,提交者日期仍然是你进行修改的那一刻,而不是原始日期,希望这是你试图获得的?
git commit -c @ --reset-author
--reset-author
更新作者信息,包括时间戳。