How to Revert to a Previous Commit in Github
- George Apostolov
How to Revert to a Previous Commit in Github: step-by-step guide
Go to your repository on Github and click on the 'Commits' link.
You will be directed to the commit history and click on the clipboard icon to copy the unique ID of the commit you want to revert.
Go to the visual studio code, open up a terminal and type 'git revert' and past the unique ID or if it's a merge commit type m1 and paste the hash.
It creates a new commit that undoes the changes introduced by a specific commit. Your history remains intact.
By following these steps, you can easily revert a previous commit.
Quick answer: To revert to a previous commit in GitHub, open your repository's commit history on GitHub to copy the commit's unique ID using the clipboard icon. Then, open your terminal in Visual Studio Code, type git revert followed by the ID to create a new commit that undoes the changes while keeping your history intact.
About this GitHub tutorial
Undo specific changes in GitHub without losing your history by copying a commit ID and using the revert command in your terminal. This guide shows how to revert to a Previous Commit in Github in 5 steps, starting with "Go to your repository on Github and click on the 'Commits' link" and finishing with "By following these steps, you can easily revert a previous commit". The interactive demo above is a click-through copy of the real GitHub interface, so you can rehearse each step before doing it in your own account.
Frequently asked questions
How many steps does it take to revert to a Previous Commit in Github?
5 steps. Each one is listed in order above, and the demo highlights exactly where to click.
Can I try it without changing my own account?
Yes. Clicking through the demo doesn't touch your GitHub data or settings. Once you know the flow, repeat it in your own workspace.
This tutorial is filed under GitHub. Related guides: How to Search Code in Github, How to See Commit History in Github and How to Set Up a Github Repository. Last reviewed 05 Oct 2026.
Create your first interactive demo in minutes
No credit card required • Start building today





