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
- Go to your repository on GitHub and click on the Commits link.
- In the commit history, click the clipboard icon to copy the unique ID of the commit you want to revert.
- 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.
- A new commit is created that undoes the changes from the specified commit, leaving your full commit history intact.
- By following these steps, you can easily revert a previous commit without losing any project history.



