- The CI/CD Guy
- Posts
- Git Reset vs Git Revert: What’s the Difference?
Git Reset vs Git Revert: What’s the Difference?
Tech Series #4 [devops, git, github, vcs]
Your Weekly Dose of DevOps & Lifestyle
git reset
or git revert
? This article breaks down the differences, use cases, and best practices, so you always pick the right tool for the job.
Explore →
★ Remote work productivity tips from top tech leaders.
★ Upcoming tech conferences you shouldn't miss.
Discover how combining small, consistent daily actions with occasional “Boost Days”—where you go all in—can help you achieve your goals faster, stay motivated, and make progress feel both sustainable and exciting.
Git Reset vs Git Revert: What’s the Difference?
Ever found yourself needing to undo changes you made, only to end up Googling which command to use—was it git reset
, git revert
, or something else? Even then, it’s easy to feel unsure about what’s actually happening behind the scenes.
Well, in the next two minutes, you’ll understand these concepts—and hopefully remember them for life.
Introduction
Git is something everyone in the tech domain should know, regardless of their specific role. In our day-to-day work, we often just scratch the surface of what Git can do. However, there are certain situations we encounter quite frequently—like needing to undo changes at any stage, whether those changes are only in your working directory, already committed, or even pushed to the remote server. Today, we’ll demystify this scenario. So, without further ado, let’s jump into the concepts.
Concept Breakdown
1. What is git revert?
git revert
is a way to go back to a previous state by creating a new commit that undoes the changes made by the commit you want to revert.
Analogy: Suppose you accidentally transfer money to the wrong account. The bank doesn’t delete the transaction; instead, they create a new transaction that moves the money back. Both transactions are visible in your statement.
That’s how git revert
works—it creates a new commit that undoes the changes of a previous commit, but both actions remain in your project’s history.
2. What is git reset?
git reset
is another way to return your repository to a previous state, but it works differently from git revert
. Instead of creating a new commit to undo changes, git reset
actually removes all commits after the one you specify, effectively rewriting your project’s history. It does this by moving the branch pointer back to the chosen commit, erasing the commits that came after it from your local history
This means those commits are no longer part of your branch’s history—they’re gone, as if they never happened (unless they’ve been pushed to a remote repository or referenced elsewhere). Because of this, git reset
is best used for local or private branches, and not for branches shared with others
Analogy: Imagine you have a time machine that lets you travel back to a specific moment in your life. When you use it, everything that happened after that moment is erased, as if those events never took place.
git reset works the same way: it takes your project back to a previous point and wipes out everything that happened after.
Comparison Table
Feature/Aspect | git revert | git reset |
---|---|---|
Purpose | Create a new commit that undoes the changes of a specific previous commit, preserving the project history | Move the branch pointer to a previous commit, effectively removing all commits after that point from the branch history |
Use Case | Safely undo changes in a public/shared branch; maintain a visible record of all changes and corrections | Remove unwanted commits from local/private branches before pushing; rewrite history to clean up mistakes or unwanted changes |
Risk/Impact | Non-destructive: does not delete any commits, keeps history intact; safe for collaboration | Destructive: can permanently remove commits from history (if not referenced elsewhere); risky for shared branches, can cause loss of work and collaboration issues if misused |
Practical Example
Scenario: Undo commit c3

Using Revert
Command: git revert HEAD
or git revert c3
Outcome: A new commit c4
will be created which will undo the changes made by commit c3.

Using Reset
Command: git reset HEAD~1
or git reset c2
Outcome: The branch pointer will move to commit c2
essentially removing all the commits after it, in this case commit c3

Mental Tattoo
If others can see it, revert it. If it’s just you, reset it.
Revert = Repair in Public:
Usegit revert
on shared or public branches. It safely undoes changes by adding a new commit, keeping the history clear for everyone.Reset = Rewrite in Private:
Usegit reset
only on your own local or private branches. It rewrites history by removing commits, but can cause issues if others are collaborating.
One-line memory hook:
Revert for the world, reset for yourself.
While Git offers multiple ways to achieve similar results, what truly distinguishes a professional from an amateur is the ability to choose the right method for the situation. So, the next time you find yourself facing this dilemma, just remember the mental tattoo above to help you take the right action.