3 ms·
git reset --soft HEAD^ # make changes so index only contains what you want git commit -a -C ORIG_HEAD of if you prefer: git config --global alias.undo r
by iam-TJ 4y ago
git reset --soft HEAD^
# make changes so index only contains what you want
git commit -a -C ORIG_HEAD
of if you prefer:
git config --global alias.undo reset --soft HEAD^
git config --global alias.redo commit -a -C ORIG_HEAD
then:
git undo
# make changes so index only contains what you want
git redo
You could use -c (--reedit-message=) instead of -C (--reuse-message=) for further flexibility.
ORIG_HEAD is set to point to the most recent HEAD when using reset. See "man git-reset" > EXAMPLES > "Undo a commit and redo".