git undo commit without remove commit history code example Example: reset last commit without losing changes git reset HEAD~1 --soft