</>
Skip to content
Git lessons (25/44)

Git — Reset

Reset Types

TypeCommandDescription
Softgit reset --softKeep changes staged
Mixedgit resetKeep changes unstaged
Hardgit reset --hardDiscard all changes

Soft Reset

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

Mixed Reset (Default)

# Undo last commit, keep changes unstaged
git reset HEAD~1

Hard Reset

# Undo last commit, discard all changes
git reset --hard HEAD~1

Reset to Specific Commit

git reset --hard commit-hash

Unstage Files

# Unstage all
git reset HEAD

# Unstage specific file
git reset HEAD file.txt

Dangerous Operations

# Discard all changes
git reset --hard HEAD

# Discard everything including untracked
git clean -fd

Mini Practice

  1. Soft reset last commit
  2. Mixed reset changes
  3. Hard reset to discard
  4. Unstage files

Up Next

Continue with Revert — reverting commits.

Related Topics

Frequently Asked Questions about Reset

What is Reset in Git?

Reset is a fundamental concept in Git. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Reset?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Reset.

Why is Reset important in Git?

Reset is essential for Git development. Understanding this concept will help you write better code and solve real-world problems more effectively.