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

后端 未结 30 3049
野性不改
野性不改 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:01

    The fastest, easiest way to do this is to use the --exec argument of git rebase:

    git rebase -i -p --exec 'git commit --amend --reset-author --no-edit'
    

    This will create a todo-list that looks like this:

    pick ef11092 Blah blah blah
    exec git commit --amend --reset-author --no-edit
    pick 52d6391 Blah bloh bloo
    exec git commit --amend --reset-author --no-edit
    pick 30ebbfe Blah bluh bleh
    exec git commit --amend --reset-author --no-edit
    ...
    

    and this will work all automatically, which works when you have hundreds of commits.

提交回复
热议问题