The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven\'t yet been pushed upstream. The new messages inherit t
Each commit is associated with two dates, the committer date and the author date. You can view these dates with:
git log --format=fuller
If you want to change the author date and the committer date of the last 6 commits, you can simply use an interactive 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
For all commits where you want to change the date, replace pick by edit (or just e), then save and quit your editor.
You can now amend each commit by specifying the author date and the committer date in ISO-8601 format:
GIT_COMMITTER_DATE="2017-10-08T09:51:07" git commit --amend --date="2017-10-08T09:51:07"
The first date is the commit date, the second one is the author date.
Then go to the next commit with :
git rebase --continue
Repeat the process until you amend all your commits. Check your progression with git status.