Rebase with Execution
A powerful flag available during a git rebase is -x
, or exec
. It allows you to run a command, or multiple commands, on each commit in the rebase.
At Hashrocket we have an alias called reset-authors
that sets your last commit's authors to the state of your current git config. Sometimes I need to do this on more than one commit in the past, and this is where -x
shines:
git rebase -i HEAD^^^ -x git reset-authors
The opens a rebase TODO list with the following details:
pick c246420 Fix README
exec reset-authors
pick cc32abc Clarify routes
exec reset-authors
pick 27b6c62 Convert HAML to ERB
exec reset-authors
Save and close, and reset-authors
will run on each commit in the list.