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

Git — Revert

Basic Revert

git revert commit-hash

Revert Last Commit

git revert HEAD

Revert Without Commit

git revert --no-commit commit-hash

Revert Merge Commit

# Revert merge
git revert -m 1 commit-hash

Revert vs Reset

FeatureRevertReset
Creates new commitYesNo
Safe for shared branchesYesNo
History preservedYesNo
Use caseUndo public changesUndo local changes

Revert Range

# Revert multiple commits
git revert commit1..commit3

Abort Revert

git revert --abort

Mini Practice

  1. Revert a commit
  2. Revert without auto-commit
  3. Revert merge commit
  4. Compare revert and reset

Up Next

Continue with Cherry Pick — cherry-picking commits.

Related Topics

Frequently Asked Questions about Revert

What is Revert in Git?

Revert 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 Revert?

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 Revert.

Why is Revert important in Git?

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