Week 29
published
Amend last commit without changing the commit message
When I want to amend the last commit, the majority of the time it is because
I forgot to add something, or more likely, I accidentally added a
# TODO
comment or
a debugger
line to
the index. Until now, my workflow was to add the changes to the index and
git commit --amend -v
(using an
alias), which causes the editor to show up with the old commit message, and
since there is no need to edit it, I would close the editor right away. Not
horribly inefficient, but when I
stumbled upon
the
--no-edit
option,
I knew it was something I needed to incorporate into my workflow.
git commit --amend --no-edit
will amend the last commit, but instead of launching the editor, it will
just keep the old commit message intact.