Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

You committed for a month with the wrong email address. How do you fix authorship?

IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → Commits carry author and committer identity that you can rewrite only by creating new commits.

What I'd do →

  1. Fix config: git config user.email "[email protected]".
  2. Unpushed or private branch: git rebase -r --root --exec 'git commit --amend --no-edit --reset-author'.
  3. Whole repo with a mapping: use git filter-repo --mailmap mailmap.txt.
  4. Force-push, and warn collaborators to re-clone.

Why → Identity is part of the commit hash, so changing it changes every descendant SHA.

Interview tip → For display-only fixes, a .mailmap file changes git log and shortlog output without rewriting history.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting