As Git user I regular come across the situation, that I need to rework one or more commits in a way which do not fit into --amend
or rebase -i
with fixup commits. Typically I would do something like
git reset HEAD~1
# hack, fix, hack
git commit -a
# argh .. do I need to retype my message?
I take sensible composed commit messages quite serious. They typically contain larger text with references & justifications for the change. Until now, I'm quite annoyed on the lengthy process to recover my old commit message via an unsorted git reflog
, git log
and copy & paste process.
Is there a better to tackle this? And how would it, if my comprises more than one commit?
Edit: After a bit thinking about this I think what I'm looking for is some git stash-like functionality for commit messages where fixup/amend commits are not appropriate.
After a git reset
, this one-liner can do it:
git commit --reuse-message=HEAD@{1}
or even shorter:
git commit -C HEAD@{1}
You can use the other options given by @user2718704.