This post was published 1115 days ago. The information contained might be outdated.
本文将简单介绍一下如何更改一个 git 提交的时间戳。
WARNING
注意,本站不建议随意执行本文中提到的任何命令,请仅在必要的情况下使用。
将最新的 commit 的时间设置为当前时间
bash
GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"将最新的 commit 的时间设置为指定时间
bash
GIT_COMMITTER_DATE="Thu Jan 1 00:00:00 1970 -0500" git commit --amend --no-edit --date "Thu Jan 1 00:00:00 1970 -0500"将任意 commit 的时间设置为当前或指定时间
使用
git rebase <commit-hash>^ -i命令进入交互式 rebase 模式,其中<commit-hash>为你想要更改的 commit 的 hash 值将第一个 commit 开头的
pick改为e(edit)按下
esc并:wq保存退出更改 commit 的时间戳
bashGIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"或者
bashGIT_COMMITTER_DATE="Thu Jan 1 00:00:00 1970 -0500" git commit --amend --no-edit --date "Thu Jan 1 00:00:00 1970 -0500"git rebase --continue完成
CommentsPrivacy Policy
What do you think?
0
0
0
0
0
0
Powered by Waline v3.7.1






