title: How do I update the author for Git commits in a merged branch?
body: <p>I have been following <a href="https://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit#3042512">various</a> guides on how to update the authors for commits in Git, but I haven't managed to update the Author for a branch that was previously merged.</p>
  
  <p>Here is what the commit history looks like:</p>
  
  <pre><code>A - B - C - D - E - F - G
           \ 1 - 2 - 3 - 4 - 5 - 6... 
  </code></pre>
  
  <p>So far I've managed to re-write the authors of the top branch. Although it's not easy to find: In something like Gitlab if you view commit C and then follow the links to the parent commit a few times you will eventually find commits where the Author hasn't updated in commits 3, 4, 5 etc.</p>
  
  <p>How can I update these?</p>
  
  <p>The script I ran to update most of the commits was:</p>
  
  <pre><code>git filter-branch -f --commit-filter '
          if [ "$GIT_AUTHOR_NAME" = "OLD-USER" ];
          then
                  GIT_COMMITTER_NAME="NEW-USER";
                  GIT_AUTHOR_NAME="NEW-USER";
                  GIT_COMMITTER_EMAIL="NEW-EMAIL";
                  GIT_AUTHOR_EMAIL="NEW-EMAIL";
                  git commit-tree "$@";
          else
                  git commit-tree "$@";
          fi' HEAD
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>Thanks to <a href="https://stackoverflow.com/a/50730163/6530181">Greg Hewgill's</a> answer, the below script fixed it</p>
  
  <pre><code>git filter-branch -f --commit-filter '
          if [ "$GIT_AUTHOR_NAME" = "OLD-USER" ];
          then
                  GIT_COMMITTER_NAME="NEW-USER";
                  GIT_AUTHOR_NAME="NEW-USER";
                  GIT_COMMITTER_EMAIL="NEW-EMAIL";
                  GIT_AUTHOR_EMAIL="NEW-EMAIL";
                  git commit-tree "$@";
          else
                  git commit-tree "$@";
          fi' -- --all
  </code></pre>