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

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

    I found the presented versions way to aggressive, especially if you commit patches from other developers, this will essentially steal their code.

    The version below does work on all branches and changes the author and comitter separately to prevent that.

    Kudos to leif81 for the all option.

    #!/bin/bash
    
    git filter-branch --env-filter '
    if [ "$GIT_AUTHOR_NAME" = "" ];
    then
        GIT_AUTHOR_NAME="";
        GIT_AUTHOR_EMAIL="";
    fi
    if [ "$GIT_COMMITTER_NAME" = "" ];
    then
        GIT_COMMITTER_NAME="";
        GIT_COMMITTER_EMAIL="";
    fi
    ' -- --all
    

提交回复
热议问题