git change author committer

How to Change Author & Committer Name & E-mail of Multiple Commits in Git?

Every git repository contains a history of commits recording all the changes that were made by the various people working on it. Each commit contains information about the author & committer name and email address to help others understand as to who made the changes. Whenever you commit a change git will automatically log your git username and email against that commit. Sometimes you may want to change the git username and email for one or more past commits in your repository’s history. In this article, we will learn how to change author & committer name & email of multiple commits in git.

How to Change Author & Committer Name & E-mail of Multiple Commits in Git?

If you are yet to make any commits to your repository, just run the following commands to set the author name and email address for your git account. Once you run the following commands, then whatever commits you make from your local system, git will automatically assign the following user information to them.

git config --global "Author Name"
git config --global "<>"

If you want to change the author information about the most recent commit, just go to your repository and run the following command. Replace username with the new username for the commit.

$ git commit --amend --no-edit --reset-author=username
$ git commit --amend --no-edit --author=username

If you want to change author for multiple commits, you can use the rebase functionality of git.

Please note, the following steps will change SHA1 hashes so be careful before using it on a branch that has already been committed.

Here is the command to update the metadata for a range of commits. Replace commit_id with the commit hash of a commit that is before all the commits whose metadata needs to be updated.

git rebase -r <commit_id> \
    --exec 'git commit --amend --no-edit --reset-author'

We use –exec option so that git commit is executed after rewriting the metadata of each commit. If you want to change metadata of first commit add –root option.

The above command will change name and email of each commit. If you only want to change only author name and not committer name, use –author ‘Author name <>’ instead of using –reset-author.

In this article, we have learnt how to change author and committer name in git repository.

Also read:

How to Clone Subdirectory of Git Repository
How to Get Remote URL of Local Git Repository
How to Remove File from Git History
How to Get One File from Another Branch in Git
How to Change Git Commit Message

One thought on “How to Change Author & Committer Name & E-mail of Multiple Commits in Git?

  1. Thanks you saved my life. I searched a lot and none on them worked for me. But the last command in this artical just worked like magic

Leave a Reply

Your email address will not be published. Required fields are marked *