You can write a new commit message to a file (say msg.txt ) and use git commit-tree , for example.
new_head=$(git commit-tree HEAD^{tree} -p HEAD^ <msg.txt) git reset
This assumes that the commit you are correcting has one parent, unless you need to supply -p HEAD^2 -p HEAD^3 ... .
It is a little ugly and low. It may be easier for you to hide your changes and use direct "change."
git stash git commit --amend git stash pop --index
As @Jefromi points out, you can also use a temporary index file for a change operation, for example.
GIT_INDEX_FILE=.git/tmpidx git reset GIT_INDEX_FILE=.git/tmpidx git commit
source share