git change author code example

Example 1: Change Git commit user name and author

# For one commit
git commit --amend --author="Author Name <[email protected]>"

# for multiple commits
git rebase -i B 
#if you need to edit A, use 
git rebase -i --root
#change the lines for both C and D from pick to edit
#Once the rebase started, it would first pause at C You would 
git commit --amend --author="Author Name <[email protected]>"
#Then 
git rebase --continue
#It would pause again at D
#Then you would 
git commit --amend --author="Author Name <[email protected]>" #again
git rebase --continue
#The rebase would complete.
#Use 
git push -f #to update your origin with the updated commits.

Example 2: How to change git author

git commit --amend --author="Author Name <[email protected]>" --no-edit

Example 3: 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 4: git reset commiter credentials

git commit --author="John Doe <[email protected]>"

Example 5: git change commit id email

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