1 Preface 当使用 git cherry-pick A^..B 来 copy 一组 commits 时,会默认使用当前的系统时间; 我们想修改一组 commits 的 author和 email,但是要保留 commit-date 和 author-date, 这时候该怎么做呢? 2 解决办法 1 git -c rebase.instructionFormat='%s%nexec GIT_COMMITTER_DATE="%cD" GIT_AUTHOR_DATE="%aD" git commit --amend --no-edit --reset-author' rebase -i ${hashid} 不使用-i,改为 -f,则不显示交互会话界面,直接执行。 默认只影响 hash-id 之后的commits,如果需要从 root 开始rebase,则使用 --root to rebase all。 3 参考 1 How to update git commit author 2 更多玩法 How to preserve the committer date in git-rebase.md……

阅读全文