Changing author of the pushed git commit in opensource project


Sometimes we have to change author of the pushed commit. How to do it without much efford?

Today I stuck on similar problem. I was using SourceTree to commit some changes to be available on my second computer… Unfortunately I didn’t realise which user is associated with it. Just after push saw wrong author next to the commit. Because I’m not very familiar with console git, quick google gave me some ideas how can I fix it.

It took me about 2 hours to try some examples and get the things works but I found a nice way that is presented below and at

CAUTION! As @Marcin wrote in comments bellow you have to be careful doing this operation. It change commit hash and can lead to problems when you cooperate with other people!

How to change author of  ALL wrong pushed commits:

  1. Open the git console in your repository location
  2. Pull the latest version
  3. Modify the script below to meet your requirements. (old_email, correct_name, correct_email)
    git filter-branch -f --env-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
    ' --tag-name-filter cat -- --branches --tags
  4. After modyfing it, paste it to console and press ENTER
  5. Verify correctness by looking at the SourceTree gui or by typing
     git log
  6. When all changes are correct, run:
     git push --force --tags origin 'refs/heads/*' 

Now all commits with the old author should be replaced and fixed 🙂

As always: subscribe to my RSS feed!
follow us in feedly

  • Be aware that by changing commit author you are changing commit hash, in other words if someone else pulled your project he/she will have terrible merge conflicts because git will think that you pulled from different repo. In git it is really a bad idea (TM) to change already pushed commit when you are working with other persons.

    • Jakub Boczek

      @0xmarcin:disqus Thanks for the good remark 🙂 I’ll put a note at the beginning of the article. I think that in specific situation it can be done but we just have to be careful.