Change the author of one Git commit

Amend author metadata without accidentally including staged changes, edit an older commit with rebase, and distinguish author identity from committer identity.

Best practices
Illustration of Git branches and version history

For the latest commit, amend its author explicitly. If you intend to change metadata only, --only without paths keeps currently staged changes out of the amended commit:

git commit --amend --only --author="Zhang San <zhangsan@example.com>" --no-edit

A changed author creates a different commit ID. The original author date is normally retained; the committer identity and time reflect the new commit operation. Inspect the result with git show --no-patch --format=fuller HEAD.

Edit an older commit

Start with a clean checkout and save a backup branch:

git branch backup-before-author-fix
git rebase -i 'a1b2c3d^'

Mark the target commit edit, then amend and continue:

git commit --amend --only --author="Zhang San <zhangsan@example.com>" --no-edit
git rebase --continue

Changing that commit also changes the IDs of descendants replayed on top of it. Use git rebase -i --root to include the first commit; the parent expression does not work for a root. Ordinary rebase flattens merge structure, so inspect a merge-containing range before choosing this workflow.

Author and committer are separate fields

--author sets the recorded author. A one-command committer override in a POSIX shell looks like this:

GIT_COMMITTER_NAME="Zhang San" GIT_COMMITTER_EMAIL="z@example.com" \
  git commit --amend --only --no-edit

To prevent future mistakes, set repository-specific defaults with git config user.name and git config user.email. Conditional includes can select identities by directory. Commit metadata is an attribution record, not authentication proof.

Change an identity across history

For a broader migration, the separately installed git-filter-repo can rewrite email fields. Use a disposable fresh clone and an exact mapping you have reviewed, for example:

git filter-repo --email-callback '
return b"new@example.com" if email == b"old@example.com" else email
'

The email callback affects both author and committer email fields. It is wider in scope than editing one commit and can change many refs and invalidate signatures. Review its fresh-clone protections, rewritten refs, and remote handling before publishing anything.

FAQ

Why was the push rejected? A rewrite may no longer fast-forward the remote branch. Coordinate the replacement and use an appropriate explicit lease; do not blindly force a shared branch.

Will this fix GitHub attribution? An email associated with your account helps GitHub associate commits. Contribution-graph eligibility has additional conditions, including branch and repository context. Updating the email alone is not a universal contribution-count fix.

See git-commit, git-filter-repo, and GitHub contribution troubleshooting.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting