How Git Handles Date Changes in Old Commits and Why It Rewrites History
Every Git commit stores metadata including author date, committer date, and message, all of which are hashed into the commit object. Changing even a single timestamp generates a completely new commit hash, meaning history must be rewritten rather than simply edited. For the most recent commit, developers can use the git commit --amend command combined with the GIT_COMMITTER_DATE environment variable to update both timestamps. Modifying an older commit requires an interactive rebase, where Git stops at the target commit, allows an amendment, then rebuilds all subsequent commits on top. Rewriting history that has already been pushed to a shared repository requires a force push and can disrupt collaborators who have based work on the original commits.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in