如何从另一个提交复制提交元数据(作者、日期)

How to copy commit metadata (author, date) from another commit

我确信 git 中有一种方法可以做到这一点,但我的搜索结果是空的。有没有一种简单的方法可以从一次提交中获取消息、提交作者、提交日期和其他信息,并用这些数据修改第二次提交,而无需复制实际的提交内容?

您可以使用 -c 标志:

$ git commit --amend --no-edit -c <other commit hash>
git commit --amend --reuse-message=<source commit hash>