如果要更改最近6次提交的作者日期和提交者日期,可以使用交互式rebase:
git rebase -i HEAD~6
pick c95a4b7 Modification 1 pick 1bc0b44 Modification 2 pick de19ad3 Modification 3 pick c110e7e Modification 4 pick 342256c Modification 5 pick 5108205 Modification 6 # Rebase eadedca..5108205 onto eadedca (6 commands) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # d, drop = remove commit
對於要更改日期的所有提交,請將git status
替換為edit
(或僅更改為e
),然后保存並退出編輯器。
您現在可以通過以ISO-8601格式指定作者日期和提交者日期來修改每個提交:
GIT_COMMITTER_DATE="2017-10-08T09:51:07" git commit --amend --date="2017-10-08T09:51:07"
第一個日期是提交日期,第二個日期是作者日期。
然后轉到下一個提交:
git rebase --continue
重復此過程,直到您修改所有提交。 通過git status
查看您的進展。