Rolling back changes in GitHub means returning your project to a previous state. The safest methods are: reverting individual commits (creates new undo commits), reverting entire pull requests (undoes a full feature at once), or browsing an old commit to copy previous file contents. Reverting is different from resetting — revert preserves history while reset erases it. Non-technical users should always use revert, never reset.
What Rollback Means and When You Need It
A rollback is when you take your project back to a previous working state. This is one of the most important skills in version control — things break, features don't work as expected, and AI tools sometimes generate code that causes problems. GitHub provides several safe ways to roll back without losing your project history. The most common approach is reverting, which creates new commits that undo previous changes. You can revert a single commit (to undo one specific change), revert an entire pull request (to undo a complete feature or update), or browse an old commit to manually copy previous file contents. The key distinction to understand is between revert and reset. Revert is safe — it keeps the full history and adds a new 'undo' commit. Reset is dangerous — it erases commits from history and can cause data loss. If you are a non-technical founder working with AI tools like Lovable, V0, or Replit, you should always use revert for rollbacks.
Prerequisites
- A GitHub account (free plan works)
- A repository with multiple commits or pull requests
- Write access to the repository
Step-by-step guide
Revert a single commit from the commit history
Revert a single commit from the commit history
Navigate to your repository on github.com and click the commit count above the file list to open the commit history. Find the specific commit you want to undo and click on its message to open the commit detail page. Click the "..." (three dots) menu near the top-right of the commit and select "Revert." GitHub creates a new pull request containing a commit that does the exact opposite of the original — additions become deletions and vice versa. Review the diff, then click "Merge pull request" followed by "Confirm merge." The changes from that commit are now undone.
Expected result: A revert pull request is created and merged, undoing the specific commit's changes.
Revert an entire pull request to undo a feature
Revert an entire pull request to undo a feature
If a feature was delivered through a pull request (which may contain multiple commits), you can revert the entire PR at once. Go to the "Pull requests" tab, click "Closed" to see merged PRs, and open the one you want to undo. At the bottom of the pull request conversation page, you'll see a "Revert" button. Click it. GitHub creates a new pull request that reverses all the changes from every commit in the original PR. Review this revert PR to make sure it looks correct, then click "Merge pull request" and "Confirm merge." This is the fastest way to undo an entire feature.
Expected result: A revert PR is created that undoes all changes from the original pull request. After merging, the feature is fully rolled back.
Browse an old commit to view previous file states
Browse an old commit to view previous file states
Sometimes you don't want to revert a commit — you just want to see what a file looked like before a change. Go to the commit history and find a commit from before the change you're concerned about. Click the commit hash (the short alphanumeric code like "a3f29b1" on the right side of the commit entry). GitHub shows you the entire repository as it was at that point in time. You can browse files, read code, and even click the "Browse files" button to navigate the full file tree. This does not change anything in your current repository — it's purely a read-only view of the past.
Expected result: You see the repository's files as they existed at the selected point in time, without altering the current state.
Manually restore a file from an older version
Manually restore a file from an older version
If you found an old version of a file that you want to bring back, you can copy its contents. While browsing an old commit (from the previous step), navigate to the file you want to restore and click on it. Click the "Raw" button to see the plain text content. Select all the text (Ctrl+A or Cmd+A) and copy it (Ctrl+C or Cmd+C). Now go back to your current repository (click the repository name in the breadcrumb). Open the same file, click the pencil icon to edit, select all existing content, and paste the old version. Add a commit message like "Restore file to previous version" and click "Commit changes."
Expected result: The file in your current repository now contains the content from the older version, saved as a new commit.
Use GitHub Desktop to revert commits visually
Use GitHub Desktop to revert commits visually
Open GitHub Desktop and select your repository. Click the "History" tab in the left panel to see all commits in chronological order. To undo a single commit, right-click it and select "Revert Changes in Commit." GitHub Desktop creates a local revert commit. To undo multiple commits, right-click each one individually, starting from the most recent and working backward. After all reverts are created, click "Push origin" in the top toolbar to send the reverts to GitHub. This method gives you a visual overview of what you're undoing before pushing changes.
Expected result: Revert commits appear in your local History tab and are pushed to GitHub, undoing the selected changes.
Complete working example
1# Rollback Strategies23## Quick Decision Guide45| Situation | Best Approach |6|------------------------------------|--------------------------|7| Undo one specific commit | Revert the commit |8| Undo a full feature/PR | Revert the pull request |9| See what a file used to look like | Browse old commit |10| Restore a file to a previous state | Copy from old commit |11| Undo the last several commits | Revert each one backward |1213## Safe vs Dangerous1415**SAFE (always use these):**16- Revert commit (creates undo commit)17- Revert pull request (creates undo PR)18- Browse old commits (read-only)1920**DANGEROUS (avoid unless you have a developer):**21- git reset --hard (erases commits)22- git push --force (rewrites remote history)23- Deleting branches with unmerged workCommon mistakes when rolling back Changes in GitHub
Why it's a problem: Using git reset instead of git revert
How to avoid: Reset erases commits from history, which can cause data loss and conflicts for collaborators. Always use revert, which creates a new commit that safely undoes changes while preserving history.
Why it's a problem: Reverting commits in the wrong order
How to avoid: When reverting multiple commits, always start with the most recent one and work backward. Reverting in the wrong order can cause merge conflicts.
Why it's a problem: Forgetting to merge the revert pull request
How to avoid: When you click Revert on github.com, it creates a pull request — not an immediate change. You must open the PR and click 'Merge pull request' for the rollback to take effect.
Why it's a problem: Rolling back without understanding what will break
How to avoid: Before reverting, read the commit diff to understand what code will be removed. If other parts of your app depend on that code, the revert could cause new errors. Test after every rollback.
Best practices
- Always revert instead of reset — it is safer and preserves your complete project history
- Revert entire pull requests when you want to undo a complete feature, not just individual commits
- Browse old commits read-only before deciding to rollback — you might not need to revert after all
- Start reverting from the most recent commit and work backward to avoid merge conflicts
- Test your application after every rollback to ensure nothing else broke
- Keep a changelog or notes about what you reverted and why for future reference
- If rolling back AI-generated changes from tools like Cursor or Replit, revert the entire PR they created for the cleanest undo
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
My GitHub repository has several bad commits that broke my web app. Explain how to roll back to a working state using only the GitHub website and GitHub Desktop — no terminal commands.
Frequently asked questions
What is the difference between revert and reset?
Revert creates a new commit that undoes changes, keeping the full history visible. Reset moves the branch pointer backward, effectively erasing commits. Revert is safe for shared repositories. Reset should only be used by experienced developers in specific situations.
Can I rollback to a specific date?
Not directly by date, but you can browse the commit history and find the last commit before the date you want. Then either revert all commits after that point, or browse the old commit to manually copy file contents.
What if reverting causes merge conflicts?
This can happen when code has changed significantly since the original commit. GitHub will show the conflicts in the revert pull request. If you are not comfortable resolving conflicts, ask a developer for help or contact RapidDev.
Can I rollback changes made by AI tools?
Yes. Changes from AI tools like Lovable, V0, or Replit are regular commits and pull requests. You can revert them the same way as any other change — either by reverting individual commits or reverting the entire pull request.
Can RapidDev help me with a complex rollback?
Yes. RapidDev's engineering team handles complex rollback scenarios including multi-commit reverts, merge conflict resolution, and selective rollbacks where you want to keep some changes while undoing others.
Will my deployed site update after a rollback?
If your site deploys automatically from GitHub (through Vercel, Netlify, or GitHub Pages), then yes — merging the revert PR will trigger a new deployment with the rolled-back code. Check your deployment platform to confirm.
Can I preview what my project will look like after a rollback before actually doing it?
Yes. Browse the old commit in the commit history to see the previous file state. You can also create the revert PR without merging it and review the diff to see exactly what will change.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation