How do you undo the last commit but keep your changes?
Run git reset --soft HEAD~1 to keep the changes staged, or git reset HEAD~1 to keep them unstaged. The commit disappears from the branch while your work stays in the files.
Explain it simply
You committed too early, perhaps with the wrong message or half the files. You want to rewind one step without losing a line of code.
HEAD~1 means the commit before the current one. Resetting the branch there removes the last commit from history, but unlike --hard, soft and mixed leave your files alone. Use soft if you plan to commit again right away, mixed if you want to re-pick what to stage. Only do this before pushing; otherwise prefer revert.
Example
git log --oneline -2
# b2c3d4e Add cart and wishlist
# a1b2c3d Add header
git reset HEAD~1
git status # cart and wishlist files appear as modifiedWhat to say in the interview
"I run git reset --soft HEAD~1 or the default mixed reset. The commit is removed from the branch but my edits remain, staged with soft or unstaged with mixed. I do this only for unpushed commits."