How to change the author and committer name and e-mail of multiple commits in Git?

后端 未结 30 3127
野性不改
野性不改 2020-11-21 04:50

I was writing a simple script in the school computer, and committing the changes to Git (in a repo that was in my pendrive, cloned from my computer at home). After several c

30条回答
  •  长发绾君心
    2020-11-21 05:05

    If the commits you want to fix are the latest ones, and just a couple of them, you can use a combination of git reset and git stash to go back an commit them again after configuring the right name and email.

    The sequence will be something like this (for 2 wrong commits, no pending changes):

    git config user.name 
    git config user.email 
    git reset HEAD^
    git stash
    git reset HEAD^
    git commit -a
    git stash pop
    git commit -a
    

提交回复
热议问题