Well, I landed on this page while searching for the same. Found a better way with many other options
git rebase -i HEAD~2
An editor will open up with the following details
pick 4f4f96f Added git ignore
pick d01e18c Added sample Blog
# Rebase 60e1cd3..d01e18c onto 60e1cd3 (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
press i, change pick
to r
or reword
, something like below
pick 4f4f96f Added git ignore
r d01e18c Added sample Blog
PRESS esc + : + wq
Another window will open up, change the commit message
PRESS esc + : + wq
git push -f