This interactive demo was created free with Storylane in 2 minutes. Create your own demo
This interactive demo was created free with Storylane in 2 minutes. Create your own demo
Start free
All Tutorials /GitHub

How to Revert to a Previous Commit in Github

Updated on:
May 12, 2026
By:
Madhav Bhandari
Use this interactive demo to learn how to safely undo a commit in your GitHub repository.

Quick summary

Reverting a previous commit in GitHub creates a new commit that safely undoes unwanted changes while keeping your commit history intact. Using the git revert command with a commit's unique hash is the recommended non-destructive way to roll back code in any repository.


Steps

  1. Go to your repository on GitHub and click on the Commits link.
  2. In the commit history, click the clipboard icon to copy the unique ID of the commit you want to revert.
  3. Open Visual Studio Code, launch a terminal, and type git revert followed by the copied commit hash — or use -m 1 and paste the hash if it is a merge commit.
  4. A new commit is created that undoes the changes from the specified commit, leaving your full commit history intact.
  5. By following these steps, you can easily revert a previous commit without losing any project history.

📌 Why this matters

Knowing how to revert a previous commit in GitHub is an essential version control skill for developers who need to undo breaking changes without rewriting history. The git revert command creates a safe, non-destructive rollback by adding a new commit that cancels out the target changes, making it ideal for shared branches and collaborative workflows. Unlike git reset, reverting preserves the full commit history, ensuring traceability and team transparency. This makes it the preferred method for undoing mistakes in production codebases or any Git repository where history integrity matters.
Your product deserves an interactive demo
Start free
Similar Articles
GitHub

How to Import a Project from GitHub to Replit

Madhav Bhandari
Director of Marketing @ Storylane
GitHub

How to Push Code from Replit to GitHub

Madhav Bhandari
Director of Marketing @ Storylane
GitHub

How to Connect Replit to GitHub

Madhav Bhandari
Director of Marketing @ Storylane
No items found.
Platform
Interactive Demos
Sandbox Demos
Buyer Hub
RepX
Integrations
Solutions
Product Marketers
Growth & Demand Gen
Sales Reps & AEs
Presales & SEs
Customer Success
Product Managers
Customers
Demo Showcase
Customer Stories
Finer Demos Club
Features
Demo Signals
Personalization
Deal Intelligence
Resources
Blog
The Plot
Tutorials
Events & webinars
Help Docs
What’s New
Demo Dundies
Company
Careers
Pricing
Partners
Contact
Trust Center
Backed by
Chrome Extension Icon
Chrome extension
Download
Desktop app
Download
Built in San Francisco Bay Area - ©2026 Storylane
Privacy PolicyTerms & Conditions
X Corp (formerly Twitter)LinkedIn
This website uses cookies to ensure you get the best experience on our website. Learn More
Got it
This website uses cookies to ensure you get the best experience on our website. Learn More
Got it