Git修改舊提交的時間


如果要更改最近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查看您的進展。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM