I have been following various 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.
Here is what the commit history looks like:
A - B - C - D - E - F - G
\ 1 - 2 - 3 - 4 - 5 - 6...
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.
How can I update these?
The script I ran to update most of the commits was:
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
Edit
Thanks to Greg Hewgill's answer, the below script fixed it
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