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

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

    You can also do:

    git filter-branch --commit-filter '
            if [ "$GIT_COMMITTER_NAME" = "" ];
            then
                    GIT_COMMITTER_NAME="";
                    GIT_AUTHOR_NAME="";
                    GIT_COMMITTER_EMAIL="";
                    GIT_AUTHOR_EMAIL="";
                    git commit-tree "$@";
            else
                    git commit-tree "$@";
            fi' HEAD
    

    Note, if you are using this command in the Windows command prompt, then you need to use " instead of ':

    git filter-branch --commit-filter "
            if [ "$GIT_COMMITTER_NAME" = "" ];
            then
                    GIT_COMMITTER_NAME="";
                    GIT_AUTHOR_NAME="";
                    GIT_COMMITTER_EMAIL="";
                    GIT_AUTHOR_EMAIL="";
                    git commit-tree "$@";
            else
                    git commit-tree "$@";
            fi" HEAD
    

提交回复
热议问题