Today I Learned

A Hashrocket project

Execute a shell command on every commit in rebase

Git rebase allows you to execute a command on any commit in a rebase:

git rebase -i -exec "git reset-authors"

The result will look something like this:

pick xxxyyy Do stuff to things
exec git reset-authors
pick yyyzzz Do things to stuff
exec git reset-authors

It is very useful for resetting authors on multiple commits in case you forgot to set the current pair.

P.S. if you are curious about what git reset-authors does check out our .gitconfig in Hashrocket’s dotfiles:

[alias]
reset-authors = commit --amend --reset-author -CHEAD

https://github.com/hashrocket/dotmatrix/blob/master/.gitconfig#L18