How to change the user name or the email of a commit ?
#Checkout the branch you want to insert the commits
git checkout hotfix/Bug-123 #Pick the commits
git cherry-pick 09c075bcd46af4bc94f1d2f8341b0b698506fc9c
#Push the branch
git push origin hotfix/Bug-123
Merge multiple commits in to one
Example : Merge last 4 commits in to one
git rebase -i HEAD~4
# -> Change pick to squash the commit you want to merge
git push -f origin master
Change the user name or the email of a commit
Example 01 git -c user.name="New name" -c email@example.com commit --amend --reset-author
Example 02 git commit --amend --author "New Author Name <firstname.lastname@example.org>"
Using Interactive Rebase (For multiple commits)
git rebase -i -p <some HEAD before all of your bad commits>
Then mark all of your bad commits as "edit" in the rebase file. If you also want to change your first commit, you have to manually add it as first line in the rebase file (follow the format of the other lines). Then, when git asks you to amend each commit, do git commit --amend --author "New Author Name <email@example.com>"
edit or just close the editor that opens, and then do git rebase --continue
to continue the rebase.
You could skip opening the editor altogether here by appending --no-edit so that the command will be: git commit --amend --author "New Author Name <firstname.lastname@example.org>" --no-edit && \
git rebase --continue