Changing author (or any other commit attribute) in existing commits
From this SOF Q&A. Linked page was showing a scenario to change committer and author's name and email from old value to new value:
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<OLD_NAME>" ];
then
GIT_COMMITTER_NAME="<NEW_NAME>";
# ...
# modify other attributes if any, then...
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
Comment in the answer was mentioning git env-filter
will change all commits,
but the one shown above allows conditional behaviour.
Editing hunk while adding commits
There are
couple
articles mentioning it, including the
git add man page. Section EDITING PATCHES
in the manual has detailed explanation.