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

后端 未结 30 3200
野性不改
野性不改 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条回答
  •  猫巷女王i
    2020-11-21 05:04

    One liner, but be careful if you have a multi-user repository - this will change all commits to have the same (new) author and committer.

    git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD
    

    With linebreaks in the string (which is possible in bash):

    git filter-branch -f --env-filter "
        GIT_AUTHOR_NAME='Newname'
        GIT_AUTHOR_EMAIL='new@email'
        GIT_COMMITTER_NAME='Newname'
        GIT_COMMITTER_EMAIL='new@email'
      " HEAD
    

提交回复
热议问题