gpt4 book ai didi

git - 如何更改 Git 中旧提交的时间戳?

转载 作者:IT王子 更新时间:2023-10-29 01:09:03 26 4
gpt4 key购买 nike

How to modify existing, unpushed commits? 的答案描述一种修改尚未推送到上游的先前提交消息的方法。新消息继承了原始提交的时间戳。这似乎合乎逻辑,但有没有办法也重新设置时间?

最佳答案

您可以进行交互式 rebase 并为要更改其日期的提交选择edit。例如,当 rebase 过程停止修改您输入的提交时:

git commit --amend --date="Wed Feb 16 14:00 2011 +0100" --no-edit

附言--date=now 将使用当前时间。

之后,您继续进行交互式 rebase 。

更改提交日期而不是作者日期:

GIT_COMMITTER_DATE="Wed Feb 16 14:00 2011 +0100" git commit --amend --no-edit

上面的行设置了一个环境变量 GIT_COMMITTER_DATE 用于修改提交。

一切都在 Git Bash 中进行了测试。

关于git - 如何更改 Git 中旧提交的时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/454734/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com