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
A single command to change the author for the last N commits:
git rebase -i HEAD~4 -x "git commit --amend --author 'Author Name ' --no-edit"
NOTES
--no-edit
flag makes sure the git commit --amend
doesn't ask an extra confirmationgit rebase -i
, you can manually select the commits where to change the author,the file you edit will look like this:
pick 897fe9e simplify code a little
exec git commit --amend --author 'Author Name ' --no-edit
pick abb60f9 add new feature
exec git commit --amend --author 'Author Name ' --no-edit
pick dc18f70 bugfix
exec git commit --amend --author 'Author Name ' --no-edit
You can then still modify some lines to see where you want to change the author. This gives you a nice middle ground between automation and control: you see the steps that will run, and once you save everything will be applied at once.