Skip to main content
RapidDev - Software Development Agency
github-for-non-tech

How to Undo a Commit in GitHub

To undo a commit in GitHub, use the Revert button on the commit's page or right-click the commit in GitHub Desktop and select 'Revert Changes in Commit.' Reverting creates a new commit that undoes the changes from the original, keeping your full history intact. This is the safest approach because it does not delete history or affect other commits. Never use destructive methods like force-pushing unless a developer guides you.

What you'll learn

  • How to revert a commit using the GitHub web interface
  • How to revert a commit using GitHub Desktop
  • Why reverting is safer than deleting or resetting commits
  • How to verify that the revert worked correctly
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner7 min read5 minutesAny modern web browser; GitHub Desktop for Windows or macOSMarch 2026RapidDev Engineering Team
TL;DR

To undo a commit in GitHub, use the Revert button on the commit's page or right-click the commit in GitHub Desktop and select 'Revert Changes in Commit.' Reverting creates a new commit that undoes the changes from the original, keeping your full history intact. This is the safest approach because it does not delete history or affect other commits. Never use destructive methods like force-pushing unless a developer guides you.

Understanding How Undo Works in GitHub

Unlike a word processor where you can press Ctrl+Z to undo your last action, GitHub's undo works differently. Every commit in GitHub is a permanent record of a change. You cannot simply delete a commit from history (at least not safely). Instead, GitHub uses a concept called reverting — which creates a brand-new commit that does the exact opposite of the original. If the original commit added 10 lines of code, the revert commit removes those same 10 lines. If the original deleted a file, the revert recreates it. This approach keeps your project history complete and transparent: anyone looking at the history can see what was done and what was undone. Reverting is the recommended approach for non-technical users because it is safe, non-destructive, and can itself be undone if needed. This is especially important when working with AI tools like Lovable or V0, which may generate commits that you later decide to roll back.

Prerequisites

  • A GitHub account (free plan works)
  • A repository with at least one commit you want to undo
  • Write access to the repository (you must be the owner or a collaborator)

Step-by-step guide

1

Find the commit you want to undo

Navigate to your repository on github.com. Click the clock icon with the commit count above the file list (for example, "87 Commits") to open the commit history page. Browse the list to find the commit you want to undo. Each commit shows its message, author, and date. If you know a keyword from the commit message, use the search bar at the top to filter. Click on the commit message to open the full commit detail page, where you can see exactly what was changed — green lines show what was added, red lines show what was removed.

Expected result: You are viewing the full commit detail page with the diff showing all changes.

2

Click the Revert button to create a revert commit

On the commit detail page, look for the "Revert" button. On GitHub's web interface, you may need to click the "..." (three dots) menu button near the top-right of the commit page and select "Revert" from the dropdown. GitHub will create a new pull request that contains the revert — a new commit that undoes all the changes from the original commit. Review the pull request to make sure the revert looks correct: the changes should be the mirror image of the original (additions become deletions and vice versa). If everything looks right, click "Merge pull request" and then "Confirm merge."

Expected result: A new pull request is created with the revert changes. After merging, the original commit's changes are undone.

3

Revert a commit using GitHub Desktop

If you prefer using GitHub Desktop, open the application and select your repository from the dropdown in the top-left. Click the "History" tab in the left panel to see the commit history. Find the commit you want to undo, right-click on it, and select "Revert Changes in Commit" from the context menu. GitHub Desktop creates a new revert commit locally. You'll see it appear at the top of the History list with a message like "Revert 'original commit message'." Click "Push origin" in the top toolbar to send the revert to GitHub.

Expected result: A revert commit appears in your History tab and is pushed to GitHub after clicking Push origin.

4

Verify the revert was successful

Go back to your repository on github.com and check the files that were affected by the original commit. They should now be back to their previous state. Click the commit history to see the new revert commit — its message will start with "Revert" followed by the original commit message in quotes. Click on the revert commit to see its diff: the changes should be the exact opposite of the original commit. If you had added a file in the original, it should now be deleted. If you had changed a line, it should be changed back.

Expected result: The repository files are restored to their state before the original commit, and the revert commit is visible in history.

Complete working example

CHANGELOG.md
1# Changelog
2
3All notable changes to this project are documented here.
4
5## Revert Guide Quick Reference
6
7### GitHub Web (browser)
81. Go to Commits page
92. Click the commit you want to undo
103. Click "..." menu Revert
114. Review the pull request
125. Merge the revert PR
13
14### GitHub Desktop
151. Open the repository
162. Click History tab
173. Right-click the commit
184. Select "Revert Changes in Commit"
195. Click Push origin
20
21### Important Notes
22- Reverting does NOT delete history
23- A revert creates a NEW commit
24- You can revert a revert if you change your mind
25- Always review the diff before confirming

Common mistakes when undoing a Commit in GitHub

Why it's a problem: Trying to delete a commit from history instead of reverting it

How to avoid: Never try to delete commits or force-push to erase history. Use the Revert feature, which safely creates a new commit that undoes the changes while preserving the complete history.

Why it's a problem: Reverting the wrong commit

How to avoid: Always read the commit diff carefully before reverting. Check the commit message, author, and date to confirm it is the correct commit. You can revert the revert if you make a mistake.

Why it's a problem: Not merging the revert pull request

How to avoid: When reverting through the GitHub web interface, the revert is created as a pull request. You must click 'Merge pull request' and then 'Confirm merge' for the revert to take effect.

Why it's a problem: Forgetting to push the revert from GitHub Desktop

How to avoid: After right-clicking and selecting 'Revert Changes in Commit' in GitHub Desktop, click the 'Push origin' button in the toolbar to send the revert to GitHub.

Best practices

  • Always use Revert instead of trying to delete commits — it preserves full history and is safe
  • Read the commit diff before reverting to make sure you are undoing the correct changes
  • Write a clear commit message for the revert explaining why you undid the change
  • If an AI tool like Lovable or V0 generated a commit you want to undo, use the same Revert process
  • Test your application after reverting to make sure it still works correctly
  • Remember that you can revert a revert — so reverting is never permanent
  • For complex multi-commit undos, consider reverting each commit individually starting from the most recent

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I accidentally committed a change to my GitHub repository that broke my project. Explain how to use the Revert feature on GitHub's website to undo it, step by step, without using the terminal.

Frequently asked questions

Does reverting a commit delete it from history?

No. Reverting creates a new commit that undoes the changes. The original commit remains in the history forever. This is a feature, not a limitation — it maintains a complete audit trail.

Can I undo a revert?

Yes. Since a revert is just another commit, you can revert the revert to restore the original changes. This is one of the reasons reverting is the safest approach to undoing work.

What if I need to undo multiple commits?

Revert each commit individually, starting from the most recent one and working backward. This prevents conflicts. Alternatively, see the 'How to Rollback Changes in GitHub' tutorial for reverting an entire pull request at once.

Will reverting break my application?

It depends on what the commit changed. If the commit added a feature that other parts of your app depend on, reverting it could cause errors. Always test after reverting. If your app was built with Lovable or Cursor, you can use those tools to fix any issues the revert causes.

Can RapidDev help me safely undo changes to my repository?

Yes. RapidDev's engineering team can review your commit history, identify the right commits to revert, and handle complex rollback scenarios — especially useful when AI-generated code needs to be partially undone.

What is the difference between revert and reset?

Revert creates a new commit that undoes changes, keeping full history. Reset moves the branch pointer backward, effectively erasing commits from the branch. Revert is safe for shared repositories; reset is dangerous and should only be done by experienced developers.

Can I revert a commit someone else made?

Yes, as long as you have write access to the repository. The revert commit will be attributed to you, and the original commit remains in history attributed to the original author.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.