revert to local commit git without losing changes code example Example: reset last commit without losing changes git reset HEAD~1 --soft