git change author of all commits code example

Example 1: git change commit author for all commits

# Changes the username and email of all commits from the start.
git rebase -i --root -x "git commit --amend --author='YOUR_USERNAME <[email protected]> --no-edit'"

Example 2: git change author multiple commits

git config --global user.name "John Doe"
git config --global user.email [email protected]

git rebase -i YOUR_SHA -x "git commit --amend --reset-author -CHEAD"

Example 3: git change author of last 2 commits

git rebase -i YOUR_SHA -x "git commit --amend --author 'New Name <[email protected]>' -CHEAD"