Header

How can I change the author of multiple Git commits?

Updating the author and committer details of several commits in your repository

If you change your local commit author information, such as your name or email address, you may then wish to change the author of several older commits in your repository as a result.

There are several ways of doing this, but in this guide we'll look at updating everything after a specific commit reference.

Update the author details of historical commits

Firstly, we'll need to update the commit author in our local Git config:

$ git config --global user.name "Robert Lyall"
$ git config --global user.email "rob@deployhq.com"

Then, reset the author of all commits after a specific commit:

$ git rebase -i 956951bf -x "git commit --amend --reset-author -CHEAD"

You'll then be presented with your editor where you can confirm all the commits you want to change.

pick bef03ed Revert "Add the correct link to Brie"
exec git commit --ammend --reset-author -CHEAD
pick 74dd8b3 New folder
exec git commit --ammend --reset-author -CHEAD
pick 56aedbe remove old folder
exec git commit --ammend --reset-author -CHEAD

# Rebase 956951b..56aedbe onto 956951b (6 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label

Check through the commits in the list, and hit ctrl+x, followed by enter to apply the changes.

Proudly powered by Katapult. Running on 100% renewable energy.