Jedes Commit ist mit zwei Daten verknüpft, dem Committer-Datum und dem Autorendatum. Sie können diese Daten anzeigen mit:
git log --format=fuller
Wenn Sie das Autorendatum und das Committer-Datum der letzten 6 Commits ändern möchten, können Sie einfach eine interaktive Rebase verwenden:
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
Ersetzen Sie für alle Commits, bei denen Sie das Datum ändern möchten, pickdurch edit(oder nur e), speichern Sie den Editor und beenden Sie ihn.
Sie können jetzt jedes Commit ändern, indem Sie das Autorendatum und das Committerdatum im ISO-8601-Format angeben:
GIT_COMMITTER_DATE="2017-10-08T09:51:07" git commit --amend --date="2017-10-08T09:51:07"
Das erste Datum ist das Festschreibungsdatum, das zweite das Autorendatum.
Fahren Sie dann mit dem nächsten Commit fort mit:
git rebase --continue
Wiederholen Sie den Vorgang, bis Sie alle Ihre Commits geändert haben. Überprüfen Sie Ihren Fortschritt mit git status.