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

后端 未结 30 3201
野性不改
野性不改 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 04:58

    I use the following to rewrite the author for an entire repository, including tags and all branches:

    git filter-branch --tag-name-filter cat --env-filter "
      export GIT_AUTHOR_NAME='New name';
      export GIT_AUTHOR_EMAIL='New email'
    " -- --all
    

    Then, as described in the MAN page of filter-branch, remove all original refs backed up by filter-branch (this is destructive, backup first):

    git for-each-ref --format="%(refname)" refs/original/ | \
    xargs -n 1 git update-ref -d
    

提交回复
热议问题