Git Reset Hard Soft Mixed

Understand undoing commits with --soft, --mixed, and --hard flags.

git reset changes where the current branch pointer points:

  • --soft: Moves HEAD; keeps staged changes in the index.
  • --mixed (default): Moves HEAD; un-stages changes into working directory.
  • --hard: Discards all commits and uncommitted file modifications.

Key Takeaways: Git Reset Hard Soft Mixed

Mastering Git Reset Hard Soft Mixed helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Git Reset Hard Soft Mixed Code Example

Git
# Undo commit but keep all written code staged in index:
git reset --soft HEAD~1
Output
Uncommits last change while preserving code in staging
Run this example on your own computer. The "Get Started" lesson shows how to set it up.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services