If you're using a recent version of Git, the SHA1 of the currently-being-edited commit during an interactive rebase appears to be stored in a file named .git/rebase-merge/amend
.
This information can be combined with git commit -c <commit>/--reedit-message=<commit>
to enter the new message in an editor and preserve the original author timestamp.
Putting it all together
Do git rebase --interactive
, mark that you want to edit a commit, then
git reset HEAD^
git add -p
git commit -c $(cat .git/rebase-merge/amend)
# 1. edit commit message to say "first part" (editor seeded with original message)
# 2. save and quit
git commit -a -c $(cat .git/rebase-merge/amend)
# 1. edit commit message to say "second part" (editor seeded with original message)
# 2. save and quit
Note: If you're trying to do this portably or in a script, you should use $(git rev-parse --git-dir)
instead of .git
.
(Thanks @torek for that reminder.)