Undo

http://stackoverflow.com/questions/927358/how-do-you-undo-the-last-commit

Last commit.

Keep interim changes between

Git reset HEAD~.

Keep ‘index’. (adds).

Git reset --soft HEAD~

Remove trace (nuke)

Interim changes between B & will be lost.

Git reset --hard HEAD~
To still recover use checkout <hash>

What happens to the untracked files at B?

@. Head.

Remove the very first commit

git update-ref -d HEAD

Changes from first commit - in staging area.

Minor changes

Commit --amend
Updated: 2026 Aug 19