🕵️ SicherheitslückenÜber Zero-Day-Lücke: Angreifer schleusen Backdoor in Onlineshops ein(07.09.2026 um 13:16 Uhr)
⚠️ Malware / Trojaner / VirenAuch im Standby: LG-Fernseher wohl anfällig für weitreichende Spionageangriffe(08.09.2026 um 10:54 Uhr)
🕵️ SicherheitslückenMehrere Bugs beseitigt: Microsoft verteilt Notfallupdates für Windows(15.09.2026 um 08:57 Uhr)
🔧 AI Nachrichten Datenschutz bei KI: OpenAI lässt KI-Prompts von Menschen lesen(15.09.2026 um 09:06 Uhr)
🔧 AI Nachrichten GPT-6 Astra schafft Portal, verbrennt dabei rund 500 Euro an Tokens(12.09.2026 um 16:00 Uhr)
🪟 Windows TippsPerformance-Test: Windows 11 muss sich Linux geschlagen geben(13.09.2026 um 11:00 Uhr)
🕵️ SicherheitslückenÜber Zero-Day-Lücke: Angreifer schleusen Backdoor in Onlineshops ein(07.09.2026 um 13:16 Uhr)
⚠️ Malware / Trojaner / VirenAuch im Standby: LG-Fernseher wohl anfällig für weitreichende Spionageangriffe(08.09.2026 um 10:54 Uhr)
🕵️ SicherheitslückenMehrere Bugs beseitigt: Microsoft verteilt Notfallupdates für Windows(15.09.2026 um 08:57 Uhr)
🔧 AI Nachrichten Datenschutz bei KI: OpenAI lässt KI-Prompts von Menschen lesen(15.09.2026 um 09:06 Uhr)
🔧 AI Nachrichten GPT-6 Astra schafft Portal, verbrennt dabei rund 500 Euro an Tokens(12.09.2026 um 16:00 Uhr)
🪟 Windows TippsPerformance-Test: Windows 11 muss sich Linux geschlagen geben(13.09.2026 um 11:00 Uhr)

🔧 Programmierung 🕛 vor 2 Monaten 4 Min Lesezeit
0

How to Change the Date of an Old Git Commit

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Sooner or later, most Git users encounter a situation where a commit has the wrong timestamp.



Maybe your system clock was incorrect.



Maybe you imported commits from another repository.



Maybe you rebased a branch and unexpectedly changed commit dates.



Or maybe you're simply curious about how Git stores commit metadata.



In this article, we'll look at how to change the date of an old Git commit and why the process is more complicated than most developers expect.






Why Git Commit Dates Matter



Every Git commit contains more than just code changes.



A commit also stores metadata, including:




  • Author

  • Committer

  • Author Date

  • Commit Date

  • Commit Message



You can inspect a commit with:




CODE
git show --pretty=fuller HEAD






Example:




CODE
AuthorDate: Mon Jul 1 10:00:00 2026 +0000
CommitDate: Mon Jul 1 10:00:00 2026 +0000






These timestamps become part of the commit object itself.



This means changing a date creates a new commit hash.



We'll come back to that later.









Changing the Date of the Last Commit



If you only need to modify the most recent commit, Git provides a relatively straightforward solution.




CODE
GIT_COMMITTER_DATE="2026-07-01T10:00:00" \
git commit --amend --no-edit --date="2026-07-01T10:00:00"






After running the command:




  • Author Date is updated

  • Commit Date is updated

  • Commit hash changes



You can verify the result:




CODE
git show --pretty=fuller HEAD






For a single commit, this approach is usually sufficient.









Changing the Date of an Older Commit



Things become more complicated when the commit is not the latest one.



Imagine a history like this:




CODE
A
B
C
D
HEAD






Suppose you want to change the date of commit B.



Git cannot simply modify that commit in place.



Instead, Git must rewrite history.



The typical approach is:




CODE
git rebase -i HEAD~4






Git will open an editor:




CODE
pick A
pick B
pick C
pick D






Change the target commit:




CODE
pick A
edit B
pick C
pick D






Save and exit.



Git stops at commit B.



Now amend the date:




CODE
GIT_COMMITTER_DATE="2026-07-01T10:00:00" \
git commit --amend --no-edit --date="2026-07-01T10:00:00"






Continue the rebase:




CODE
git rebase --continue






Git rebuilds the remaining commits on top of the modified commit.









Why This Changes Commit Hashes



Many developers are surprised by what happens next.



The code hasn't changed.



The files haven't changed.



The commit message hasn't changed.



Only the timestamp changed.



Yet Git generates a completely different commit hash.



This happens because Git hashes the entire commit object.



The commit hash depends on:




  • Tree

  • Parent commit

  • Author

  • Author Date

  • Committer

  • Commit Date

  • Commit Message



Changing any of these fields creates a new object.



Even changing a timestamp by one second produces a different SHA.









Changing Dates for Multiple Commits



Now imagine changing the dates of 20 commits.



Interactive rebase becomes tedious.



You need to:




  1. Stop at each commit.

  2. Amend metadata.

  3. Continue the rebase.

  4. Resolve conflicts if they appear.



For larger repositories this quickly becomes painful.



Historically, developers used tools like:




CODE
git filter-branch






or




CODE
git filter-repo






to rewrite commit metadata in bulk.



These tools are powerful but can be intimidating if you don't regularly rewrite Git history.









Be Careful With Shared Branches



Before changing commit dates, remember that history rewriting affects commit hashes.



If you've already pushed commits:




CODE
git push origin main






and later rewrite dates:




CODE
git rebase -i






you'll need to force push:




CODE
git push --force-with-lease






This can disrupt teammates who already based work on the old history.



As a general rule:




  • Rewriting local history is usually safe.

  • Rewriting shared history requires caution.









A Simpler Alternative



After working with Git history rewriting for a while, I realized that changing commit dates often involves more commands than expected.



For a single commit:




CODE
git commit --amend






is manageable.



For multiple commits, interactive rebases become tedious and error-prone.



That's one of the reasons I built GitEditDate — a small tool that helps edit Git commit timestamps without manually stepping through complex rebase workflows.



Whether you use GitEditDate or standard Git commands, understanding how commit dates work makes history rewriting much less intimidating.









Final Thoughts



Changing the date of an old Git commit is possible, but Git intentionally makes it explicit.



A timestamp is not just a label attached to a commit.



It's part of the commit object itself.



Because of that:




  • Changing a date changes the commit hash.

  • Changing an old date rewrites history.

  • Rewriting history affects every descendant commit.



Once you understand those rules, modifying commit dates becomes much easier to reason about.



And if you've ever wondered why a simple timestamp change can trigger a cascade of new commit hashes, now you know the answer.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Über Zero-Day-Lücke: Angreifer schleusen Backdoor in Onlineshops ein
1 Quelle
Auch im Standby: LG-Fernseher wohl anfällig für weitreichende Spionageangriffe
1 Quelle
Noch vor Hugging-Face-Hack: KI-Agenten von OpenAI haben Rubygems attackiert
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Change the Date of an Old Git Commit

Thematisch verwandte Begriffe: Change, Date, Commit · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...