Mid Version Control

Explain the difference between --soft, --mixed, and --hard resets.?

Reset

Type

What It Does Example Scenario

  • -soft Moves HEAD to a previous commit

but keeps your changes staged

You committed too early and just

want to edit the message or add

more changes.

  • -mixed

(default)

Moves HEAD and unstages files but

keeps your changes in the working

directory

You want to redo your git add

selections.

  • -hard Completely resets everything —

deletes all local changes

You want to discard all work and

return to a clean state.

Example:

git reset --soft HEAD~1 # undo last commit, keep staged

git reset --mixed HEAD~1 # undo last commit, unstage files

git reset --hard HEAD~1 # undo last commit and delete changes

More from Developer Essentials

All questions for this course