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
In the case where just the top few commits have bad authors, you can do this all inside git rebase -i
using the exec
command and the --amend
commit, as follows:
git rebase -i HEAD~6 # as required
which presents you with the editable list of commits:
pick abcd Someone else's commit
pick defg my bad commit 1
pick 1234 my bad commit 2
Then add exec ... --author="..."
lines after all lines with bad authors:
pick abcd Someone else's commit
pick defg my bad commit 1
exec git commit --amend --author="New Author Name " -C HEAD
pick 1234 my bad commit 2
exec git commit --amend --author="New Author Name " -C HEAD
save and exit editor (to run).
This solution may be longer to type than some others, but it's highly controllable - I know exactly what commits it hits.
Thanks to @asmeurer for the inspiration.